android layout_weight

<LinearLayout
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
    >
      <TextView
          android:text="红色"
          android:background="#aa0000"
          android:layout_width="wrap_content"
          android:layout_height="fill_parent"
          android:layout_weight="2"/>
      <TextView
          android:text="绿色"
          android:background="#00aa00"
          android:layout_width="wrap_content"
          android:layout_height="fill_parent"
          android:layout_weight="1"/>
 当加载这个xml文件时,会计算出layout_weight的总值等于3,然后红色的textview占屏幕的3/2,绿色的占屏幕的1/3

猜你喜欢

转载自284772894.iteye.com/blog/1727881