网站栏目定位,手机网站建设公司电话咨询,h5响应式网站建设报价,学做网站设计需要多少钱项目中需要显示水平两个按钮#xff0c;且都要有间距#xff0c;如下图所示#xff1a;首先我想到的是使用权重#xff0c;然后利用水平布局#xff0c;这样应该可以实现#xff0c;但真实的情况是这样的#xff0c;代码如下#xff1a;android:layout_widthfill…项目中需要显示水平两个按钮且都要有间距如下图所示首先我想到的是使用权重然后利用水平布局这样应该可以实现但真实的情况是这样的代码如下android:layout_widthfill_parentandroid:layout_heightmatch_parentandroid:backgroundcolor/backgroundandroid:orientationvertical android:layout_widthwrap_contentandroid:layout_height1.2pxandroid:layout_marginBottom7dpandroid:backgroundcolor/white /android:layout_widthfill_parentandroid:layout_height79dpandroid:layout_weight2android:orientationhorizontalandroid:layout_margin10dp android:idid/bt1android:layout_widthfill_parentandroid:layout_height26dpandroid:backgrounddrawable/shapeandroid:layout_weight1android:text確認對沖android:textColorcolor/whiteandroid:textSize15dp /android:layout_widthfill_parentandroid:layout_height26dpandroid:backgrounddrawable/shapeyuanjiaoandroid:layout_weight1android:text取消android:textColorcolor/whiteandroid:textSize15dp /显示的结果如下如果是正常的普通按钮也确实能实现中间有一点空隙并且水平均分但对于我这个界面都使用了圆角的效果不知道什么原因没有间距所以又去查找百度有一种解决方案是中间放一个隐藏的view占据掉一些空间不过这样尝试着不太好调最后的解决方案其实是对于每一个按钮都给一个布局这样就会存在空间然后利用权重水平均分即可文件如下android:layout_widthfill_parentandroid:layout_heightmatch_parentandroid:backgroundcolor/backgroundandroid:orientationvertical android:layout_widthwrap_contentandroid:layout_height1.2pxandroid:layout_marginBottom7dpandroid:backgroundcolor/white /android:layout_widthfill_parentandroid:layout_height79dpandroid:layout_margin10dpandroid:layout_weight2android:orientationhorizontal android:layout_widthfill_parentandroid:layout_height79dpandroid:layout_margin10dpandroid:layout_weight2android:orientationhorizontal android:idid/bt1android:layout_widthfill_parentandroid:layout_height26dpandroid:layout_weight1android:backgrounddrawable/shapeandroid:text確認對沖android:textColorcolor/whiteandroid:textSize15dp /android:layout_widthfill_parentandroid:layout_height79dpandroid:layout_margin10dpandroid:layout_weight2android:orientationhorizontal android:layout_widthfill_parentandroid:layout_height26dpandroid:layout_weight1android:backgrounddrawable/shapeyuanjiaoandroid:text取消android:textColorcolor/whiteandroid:textSize15dp /运行结果如下成功解决。欢迎各位探讨布局。