layout_weight

比如:

	<LinearLayout 
	    android:layout_width="match_parent"
	    android:layout_height="wrap_content"
	    android:orientation="horizontal"
	    android:layout_marginTop="10dip"
	    style="?android:attr/buttonBarStyle"
	    >
		<Button
		    style="?android:attr/buttonBarButtonStyle" 
		    android:id="@+id/uploadpb"
		    android:layout_weight="1"
		    android:layout_width= "10dip" 
		    android:layout_height="wrap_content"
		    android:text="@string/uploadpb" />
		<Button
		    style="?android:attr/buttonBarButtonStyle" 
			android:id="@+id/downloadpb"
			android:layout_weight="1"
			android:layout_width= "10dip"
			android:layout_height="wrap_content"
			android:text="@string/downloadpb"
			/>	    
	</LinearLayout>

  

  在这个水平布局的线性布局中,我给每个按钮任意一个layout_width(否则编译时会报错),给每个按钮一个「android:layout_weight="1"」,这样就均等分配了水平空间,like this:

  

  

    用layout_weight是为了适应不同android设备的不同屏幕分辨率

原文地址:https://www.cnblogs.com/larrylawrence/p/3518449.html