在一个xml文件中执行纵向和横向的更简单方法?在android中

时间:2012-01-30 10:36:43

标签: android

我差不多完成了我的应用程序,但仍然需要确保横向方向正常,是否有任何xml代码可以放在布局中,包括纵向和横向?

很多thx

2 个答案:

答案 0 :(得分:1)

您的布局将在两个方向都有效。您可以根据此document在名为layout-landscape的文件夹中添加具有相同名称的xml,以指定横向布局。请注意,您应该处理以确保您的应用在更改方向时正常工作,因为如果您不处理方向更改,Android可能会重新创建您的视图。

答案 1 :(得分:1)

在xml中使用RelativeLayout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/boxbig" android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">

 <Button  android:layout_alignParentBottom="true" 
    android:layout_alignParentRight="true"
    android:layout_width="wrap_content" android:layout_height="wrap_content"
    android:text="Bottom and Right"
    />

</RelativeLayout>
相关问题