首页 > 移动平台 > 详细

Android——UI布局策略2

时间:2021-09-06 04:49:26      阅读:27      评论:0      收藏:0      [点我收藏+]

以该图为例

技术分享图片

 

在应用首页会遇到:ListView作为展示占满几乎全部页面,RadioGroup作为导航栏。

Android组件中,如果layout_width="match_parent",那么组件高度为父布局的所有高度。

让此组件weight="1",下面的RadioGroup才能展示出来。

 

<LinearLayout
    android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Home03Activity">

    <ListView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:id="@+id/lv"/>

    <RadioGroup
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/rg">

        <RadioButton
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:id="@+id/rb1"
            android:text="rb1"/>

        <RadioButton
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:id="@+id/rb2"
            android:text="rb2"/>

    </RadioGroup>

</LinearLayout>

 

Android——UI布局策略2

原文:https://www.cnblogs.com/remix777/p/15227919.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!