Android 之手机屏幕朝向模拟当点击按钮时,使手机朝向发生改变。 布局文件< RelativeLayout xmlns:android = "http://schemas./apk/res/android" xmlns:tools = "http://schemas./tools" android:layout_width = "match_parent" android:layout_height = "match_parent" tools: context = ". MainActivity" > < TextView android:id = "@+id/top" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:layout_centerHorizontal = "true" android:layout_centerVertical = "false" android:layout_marginTop = "10dp" android:text = "***@string/title" android:textSize = "20sp" /> < Button android:id = "@+id/btnchange" android:layout_height = "wrap_content" android:layout_width = "wrap_content" android:layout_centerHorizontal = "true" android:layout_below = "***@id/top" android:layout_marginTop = "20dp" android:text = "***@string/btntext" /> < EditText android:id = "@+id/edit" android:layout_below = "@+id/btnchange" android:layout_marginTop = "20dp" android:layout_width = "fill_parent" android:layout_height = "wrap_content" android:cursorVisible = "false" android:hint = "***@string/hinttext" /> </ RelativeLayout >S 布局文件<? xml version = "" encoding = "utf-8" ?> < resources >< string name = "app_name" > ScreenForward </ string > < string name = "title" > 手机屏幕朝向测试</ string > < string name = "btntext" > 点击更换屏幕朝向</ string > < string name = "hinttext" > 显示当前屏幕朝向</ string > </ resources > Main Activity
Android之手机屏幕朝向 来自淘豆网m.daumloan.com转载请标明出处.