zoukankan      html  css  js  c++  java
  • 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设备的不同屏幕分辨率

  • 相关阅读:
    redis内存模型、内存使用的优化
    【转】[Andriod]Xposed和VirtualXposed
    https详解
    http详解
    补码
    浮点数的二进制表示
    Go随机数
    ECDSA--圆锥曲线数字签名算法原理(摘wikepedia)
    Linux命令备忘
    【Windows】系统命令
  • 原文地址:https://www.cnblogs.com/larrylawrence/p/3518449.html
Copyright © 2011-2022 走看看