【问题标题】:Rows to take up the entire screen占据整个屏幕的行
【发布时间】:2011-08-09 15:59:35
【问题描述】:

我有一个大的线性布局(垂直)(外表)和三个小的线性布局(水平)(每行一个)。我希望里面的线性布局占据整个空间。目前它们只占用所需的空间。
这是我的代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background">


<LinearLayout android:orientation="horizontal"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content">
    <ImageButton android:src="@drawable/Tag"
                 android:onClick="tagKillHandle"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"/>
    <ImageButton android:src="@drawable/seekills" 
                 android:layout_width="wrap_content" 
                 android:onClick="seeKillsHandle" 
                 android:layout_height="wrap_content"/>       
</LinearLayout>

<LinearLayout android:orientation="horizontal"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content">
    <ImageButton android:src="@drawable/track"
                 android:onClick="trackMeHandle"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"/>
    <ImageButton android:src="@drawable/taste"
                 android:onClick="tasteHandle"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"/>           
</LinearLayout>

<LinearLayout android:orientation="horizontal"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content">
    <ImageButton android:src="@drawable/calls"
                 android:onClick="duckCallsHandle"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"/>
    <ImageButton android:src="@drawable/faq"
                 android:onClick="faqHandle"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"/>           
</LinearLayout>


</LinearLayout>

我希望行占据整个屏幕。我怎样才能做到这一点?有什么想法吗?

【问题讨论】:

    标签: android xml android-layout android-linearlayout android-button


    【解决方案1】:

    添加

    android:layout_weight="1.0"
    

    在三个内部布局中的每一个中。

    【讨论】:

    • 太棒了。谢谢你。你能告诉我如何固定宽度吗?现在他们只取所需的数量。
    • 如果您希望每行中每个元素的宽度相等,则将 android:layout_weight="1.0" 放在每个图像按钮中
    • 知道了。为每个按钮添加了 layout_width = 0.5。
    • 好..您可以通过单击答案左侧的勾号来接受答案。
    猜你喜欢
    • 1970-01-01
    • 2021-03-11
    • 2019-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多