android 小技巧,不断更新中

来源:互联网 发布:android ndk linux arm 编辑:程序博客网 时间:2024/05/12 02:50
                    android 小技巧,不断更新中

1.weightSum属性和layout_weight 结合使用

这里写图片描述
这里写图片描述
实现上图的效果,不管横竖屏button 都占屏幕的50%的

 <LinearLayout        android:layout_width="match_parent"        android:layout_height="match_parent"        android:background="#cdcdcd"        android:gravity="center"        android:weightSum="1">        <Button            android:layout_width="0dp"            android:layout_height="wrap_content"            android:layout_weight="0.5"            android:text="50%" />  <!--还可以试下80%,都有效果的-->    </LinearLayout>

这个功能在实际开发中还是蛮有用的,有很好的适配性。

0 0
原创粉丝点击