[Android开发常见问题-8] 如何让两个按钮各占屏幕一半
2013-07-16 20:55
531 查看
随着各种大屏幕的安卓机器的出现,适配问题的重要性越来越明显,这里我给大家介绍一下如何使得两个按钮各占屏幕的一半,同理也可以让3个、4个甚至更多的按钮或者其他控件来实现平均占有屏幕的宽度。
实现的代码如下:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="45dp"
android:orientation="horizontal"
android:weightSum="2" >
<Button
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#666"/>
<Button
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#888"/>
</LinearLayout>
实现的效果就是两个按钮,各占屏幕一半的宽度。
实现的代码如下:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="45dp"
android:orientation="horizontal"
android:weightSum="2" >
<Button
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#666"/>
<Button
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#888"/>
</LinearLayout>
实现的效果就是两个按钮,各占屏幕一半的宽度。
相关文章推荐
- Android开发点滴 - 如何使按钮水平垂直居中且始终占据屏幕宽度一半
- android开发两个按钮各占屏幕一半摆放的方法
- 权限执行[Android开发常见问题-4] RunTime.exec()如何以root权限执行多条指令?
- [Android开发常见问题-6] 如何检测手机当前网络是否可用?
- [Android开发常见问题-5] 如何检测耳机的插入状态
- [Android开发常见问题-12] Android开发中debug.keystore如何使用。
- [Android开发常见问题-12] Android开发中debug.keystore如何使用。
- [Android开发常见问题-4] RunTime.exec()如何以root权限执行多条指令?
- [Android开发常见问题-13] 如何在CMD中直接使用adb命令
- android开发如何更好的解决适配不同屏幕大小移动设备的问题
- 如何回答两个常见的开发求职面试问题
- [Android开发常见问题-4] RunTime.exec()如何以root权限执行多条指令?
- Android游戏开发9:触屏事件处理中的常见问题及如何禁止横竖屏切换
- 【android】两个按钮的宽度各占屏幕的一半
- 【android】两个按钮的宽度各占屏幕的一半
- [Android开发常见问题-9] android如何给PagerTitleStrip设置字体大小
- 【android】两个按钮的宽度各占屏幕的一半
- Android开发中如何解决Fragment +Viewpager滑动页面重复加载的问题
- Android应用程序开发常见问题 FAQ
- Android开发面试经——1.常见人事面试问题