android 小技巧,不断更新中
16lz
2021-01-25
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>
这个功能在实际开发中还是蛮有用的,有很好的适配性。
更多相关文章
- android gridview 属性集合
- Android应用开发之(你必须知道的android selector下的属性值)
- Android(安卓)Studio 改变app启动页面
- android之点击回退键俩次退出程序
- 四则运算第一次冲刺
- Android的ViewFlipper与GestureDetector
- Android(安卓)生成和Pull解析xml
- 越过Android中布局文件中使用onClick属性的坑
- SetContentView 到底Set去哪里呢?