_028_Android_让每个控件占据均匀的宽度

 <!--均匀让的每个按钮宽度占1/5,那么可以设置width为0dip,然后通过layout_weight去设置所在的整个的宽度的比--> 

<LinearLayout 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"
    android:orientation="horizontal"
    tools:context=".MainActivity">


    <!--均匀让的每个按钮宽度占1/5,那么可以设置width为0dip,然后通过layout_weight去设置所在的整个的宽度的比-->

    <Button
        android:id="@+id/callBtn"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:baselineAligned="false"
        android:text="call" />

    <Button
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:baselineAligned="false"
        android:text="call" />
    <Button
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:baselineAligned="false"
        android:text="call" />
    <Button
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:baselineAligned="false"
        android:text="call" />
    <Button
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:baselineAligned="false"
        android:text="call" />
    <Button
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:baselineAligned="false"
        android:text="call" />

</LinearLayout>

猜你喜欢

转载自blog.csdn.net/poiuyppp/article/details/83479353
今日推荐