android闪关灯的开启和关闭方法代码实例
1、activity_main.xml两个按钮,一个open一个close
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<TextView android:id="@+id/textView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/hello_world"/>
<Button android:id="@+id/button_open" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignLeft="@+id/textView1" android:layout_below="@+id/textView1" android:layout_marginTop="38dp" android:text="open"/>
<Button android:id="@+id/button_close" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignLeft="@+id/button_open" android:layout_below="@+id/button_open" android:layout_marginTop="50dp" android:text="close"/>
</RelativeLayout>