您的位置:首页 > 移动开发 > Android开发

android 小技巧,不断更新中

2015-06-05 14:56 295 查看
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>


这个功能在实际开发中还是蛮有用的,有很好的适配性。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: