安卓平分位置layout_weight学习记录

weight (权重)  使用把layout_width写成0   weight 为平分剩余父容器位置

两个标签平分
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_gravity=""
    android:gravity=""
    tools:context=".MainActivity">

   <LinearLayout
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:orientation="horizontal"

      >
        

       <TextView
           android:layout_width="0dp"
           android:layout_height="match_parent"
           android:layout_weight="1"
           android:text="222222" />

       <TextView
           android:layout_width="0dp"
           android:layout_height="wrap_content"
           android:layout_weight="1"
           android:text="3333333" />

   </LinearLayout>




</LinearLayout>

  

猜你喜欢

转载自www.cnblogs.com/xuexidememeda/p/10295459.html