【问题标题】:Footer at the end of the screen屏幕末尾的页脚
【发布时间】:2015-04-20 06:09:06
【问题描述】:

我没有使用 ListView。我必须在屏幕末尾显示页脚文本,而不是在布局的所有项目下方。我该怎么做?

【问题讨论】:

  • 使用FrameLayout并将Layout设置为gravity="Bottom"
  • 这是一个非常笼统的问题。这表明您在提出问题之前没有进行研究。如果您尝试搜索而不是直接在SO上询问,您可以轻松找到答案跨度>
  • 参考此链接:stackoverflow.com/questions/13277785/… 希望对您有所帮助..

标签: android android-layout


【解决方案1】:

你可以这样做

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/frag1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.5"
            android:text="Button" />

        <Button
            android:id="@+id/frag2"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.5"
            android:text="Button" />
    </LinearLayout>
</RelativeLayout>

【讨论】:

    【解决方案2】:

    使用带权重的线性布局:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" 
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <LinearLayout
            android:id="@+id/lnrContainer"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1">
    
            </LinearLayout>
    
    
        <LinearLayout
            android:id="@+id/lnrFooter"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
    
        </LinearLayout>
    
    </LinearLayout>
    

    【讨论】:

      【解决方案3】:

      我认为您可以使用 RelativeLayout 并将 layout_alignParentBottom="true" 添加到您的页脚视图中。

      【讨论】:

        猜你喜欢
        • 2015-01-13
        • 1970-01-01
        • 2021-08-02
        • 2016-08-21
        • 1970-01-01
        • 2016-11-04
        • 1970-01-01
        • 1970-01-01
        • 2021-07-12
        相关资源
        最近更新 更多