【问题标题】:Dynamically expanding empty space?动态扩展空白空间?
【发布时间】:2011-05-14 19:13:20
【问题描述】:

有没有办法将屏幕上的上部内容与下部内容分开?因此,无论上部区域中有什么,下部区域都保持在屏幕底部。我试过gravity=bottom之类的东西。我尝试在顶部和底部之间插入某种布局,希望它会保持扩展(从而将两者分开)。感谢您提供的任何帮助。

【问题讨论】:

    标签: android layout space expand


    【解决方案1】:

    答案:相对布局

    例子:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TextView
            android:text="TOP"
            android:layout_alignParentTop="true"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
        </TextView>
        <TextView
            android:text="BOTTOM"
            android:layout_alignParentBottom="true"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
        </TextView>
    </RelativeLayout>
    

    【讨论】:

    • 效果很好,我应该睁开眼睛:)。它在纵向中起作用,但是在横向中,底部对齐的东西与顶部的东西重叠。有没有办法在活动的 onCreate 中改变它,这样如果它是风景它是假的,如果它是真的肖像?感谢您的帮助
    • 尝试使用其他属性,如 android:layout_below 及以上。最好是分开进行纵向和横向布局。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-06
    • 1970-01-01
    • 1970-01-01
    • 2012-08-10
    相关资源
    最近更新 更多