【问题标题】:Android Layouts: Moving ItemsAndroid 布局:移动项目
【发布时间】:2011-04-17 04:49:52
【问题描述】:

我想知道如何将两个或多个 UI 元素对齐到屏幕底部,而不是像往常那样堆叠。

【问题讨论】:

    标签: android user-interface elements alignment


    【解决方案1】:

    类似这样的:

    <RelativeLayout
    android:id="@+id/myBottomLayout"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
       android:layout_alignParentBottom="true">
         <View
             android:id="@+id/leftItem"
             android:layout_height="wrap_content"
             android:layout_width="wrap_content">
         <View
             android:id="@+id/rightItem"
             android:layout_height="wrap_content"
             android:layout_width="wrap_content"
             android:layout_toRightOf="id/leftItem">
    </RelativeLayout>
    

    【讨论】:

    • 但我希望其他内容与顶部对齐。我可以用这个 XML 做到这一点吗?
    • 当然,我忘了提到这段代码假设父元素也是RelativeLayout。要与顶部对齐,请使其他元素与顶部对齐。如果父元素是 RelativeLayout,这将起作用。
    猜你喜欢
    • 2020-08-13
    • 2016-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多