sea*_*alz 2 xml android android-layout
我看过这里,但仍然无法解决我的问题.
我最近跳进了android(headfirst)并且一直在搞乱.我希望我的应用程序只能在横向模式下运行,无论屏幕倾斜的方向如何.
我的主屏幕基本上是一个带有背景的页面和一些在右侧对齐的按钮.
这是我的XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingLeft = "450px"
android:paddingRight = "60px"
android:paddingTop="25px"
//I have tried adding orientation commands here like the one below??
android:screenOrientation="landscape"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background = "@drawable/sign"
>
<Button
android:id="@+id/Button1"
android.layout_height="60px"
android.layout_width="30px"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="Button1"/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:id="@+id/Button2"
android.layout_height="60px"
android.layout_width="30px"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="Button2"/>
Run Code Online (Sandbox Code Playgroud)
在manifest.xml文件中添加此行.
<activity android:name=".activity" android:screenOrientation="portrait"></activity>
Run Code Online (Sandbox Code Playgroud)
如果您只想横向定位,则更改横向而不是纵向
归档时间: |
|
查看次数: |
4764 次 |
最近记录: |