需求:
在xml佈局裏面設置屏幕常亮
代碼:
在xml根佈局裏面,設置這個屬性:android:keepScreenOn="true"
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true">
<!--內容-->
</RelativeLayout>