我们的APP新做了一个放操作按钮的界面,老板要求简洁美观有内涵,按钮要均匀分布,于是参考之前的实现,设计MM给了一张图,像这样:|==============================================||==========[Button]========= ...
我们的APP新做了一个放操作按钮的界面,老板要求简洁美观有内涵,按钮要均匀分布,于是参考之前的实现,设计MM给了一张图,像这样:
|==============================================|
|==========[Button]==========[Button]==========|
|==========[Button]==========[Button]==========|
|==============================================|
当然设计MM给的是高清图片,这里只是示意一下。经过分析,需求应该是这样的:两个按钮需要排列在一行里,要求他们之间的间距、以及按钮和屏幕边缘的间距要相等,并且要撑满整个屏幕宽度。
看来并不是什么难事,利用LinearLayout的特性,使用layout_weight使得占位View大小相同,如下:
<??><RelativeLayout ="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerVertical="true"> <View android:layout_width="0dp" android:layout_height="0dp" android:layout_weight="1"/> <ImageView android:layout_width="40dp" android:layout_height="wrap_content" android:src='/images/loading.gif' data-original="@drawable/record_start" android:gravity="center_horizontal"/> <View android:layout_width="0dp" android:layout_height="0dp" android:layout_weight="1"/> <ImageView android:layout_width="40dp" android:layout_height="wrap_content" android:src='/images/loading.gif' data-original="@drawable/game" android:gravity="center_horizontal" /> <View android:layout_width="0dp" android:layout_height="0dp" android:layout_weight="1"/> </LinearLayout></RelativeLayout>
原标题:Android代码故事第一回,平均间隔的按钮
关键词:Android
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。