Android 使我的按钮样式类似于AlertDialog按钮样式
我想让我的按钮样式如下Android 使我的按钮样式类似于AlertDialog按钮样式,android,Android,我想让我的按钮样式如下 我想用我的自定义视图实现这些按钮,我的意思是不使用AlertDialog,您只需使用xml即可,如下所示: 将其放入drawable/border.xml中 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <solid
我想用我的自定义视图实现这些按钮,我的意思是不使用AlertDialog,您只需使用xml即可,如下所示: 将其放入drawable/border.xml中
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<solid android:color="#000000" />
<stroke android:width="1dip" android:color="#333333"/>
</shape>
然后在布局文件中:
<Button
...
android:background="@drawable/border"
android:textColor="#ffffff"
android:textSize="13sp"
... />
然后你可以设置你的宽度和高度,让它看起来很棒
编辑:
我建议您改用answer,最好使用内置的Android资源。如果您更喜欢使用标准的Android属性,请参阅我的答案
简而言之,为您的按钮设置
style=“?android:attr/buttonBarButtonStyle”
,并将它们放置在LinearLayout
中,该布局具有style=“?android:attr/buttonBarStyle”它靠近图像,但背景颜色不是黑色是的,但您可以将背景颜色更改为您想要的任何颜色。只需在此处更改十六进制颜色:这是最正确的答案。属性buttonBarButtonStyle在holo主题中(不确定之前的属性)设置为无边框ButtonStyle,这是OP的目标+1不幸的是,这需要API 11。它看起来不像警报对话框。按钮上方或按钮中间没有分隔符。我建议删除android:
以使用AppCompat样式。不确定它们是否与?attr/buttonBarButtonStyle
不同,但也有?attr/buttonBarPositiveButtonStyle
,?attr/buttonBarNeutralButtonStyle
和?attr/buttonBarNegativeButtonStyle
。