Android中默认情况下,几个Button并排在一个布局里会发出警告:

Buttons in button bars should be borderless

Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?android:attr/buttonBarStyle on the parent)

Button bars typically use a borderless style for the buttons. Set the style="?android:attr/buttonBarButtonStyle" attribute on each of the buttons, and set style="?android:attr/buttonBarStyle" on the parent layout
http://developer.android.com/design/building-blocks/buttons.html

网上搜得的答案:

原因:两个Buttons放在一个布局里会被判断为按钮栏,需要添加样式取消它的边框。

解决方法: 在Buttons上添加属性style="?android:attr/buttonBarButtonStyle" 。系统提示也可以在按钮的父布局上添加 style="?android:attr/buttonBarStyle" 属性

可是这样的话你的Button就没有边框了
然而你不是想让Button没有边框,只要加上属性style="@style/Widget.AppCompat.Button"或者其他样式就可以了

所以我对这种情况的理解是:
几个Button并排在一个布局里,没有设置style属性的Button会被判断为按钮栏的按钮
然而按钮栏的按钮需要取消它的边框(即添加属性style="?android:attr/buttonBarButtonStyle"

so,几个Button并排在一个布局里设置style属性就不会有问题了

支付宝红包

支付宝

微信

标签: none

仅有一条评论

  1. 双休日兼职 双休日兼职 访客 Firefox Windows XP 回复

    能解决问题的办法就是好办法

添加新评论

注意:已开启评论过滤器,无中文无法评论!
泡泡表情