【发布时间】:2013-01-21 16:49:00
【问题描述】:
我想让我的按钮样式如下
我想用我的自定义视图来实现这些按钮,我的意思是不使用 AlertDialog
【问题讨论】:
标签: android
我想让我的按钮样式如下
我想用我的自定义视图来实现这些按钮,我的意思是不使用 AlertDialog
【问题讨论】:
标签: android
如果您更喜欢使用标准的 android 属性,请参阅我的回答 here。
简而言之,为您的按钮设置style="?android:attr/buttonBarButtonStyle" 并将它们放入具有style="?android:attr/buttonBarStyle" 的LinearLayout。
【讨论】:
android: 以使用 AppCompat 样式。不确定它们是否与?attr/buttonBarButtonStyle 不同,但也有?attr/buttonBarPositiveButtonStyle、?attr/buttonBarNeutralButtonStyle 和?attr/buttonBarNegativeButtonStyle。
你可以用 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"
... />
然后你可以设置你的宽度和高度让它看起来很棒! :)
编辑: 我建议使用this 答案而不是认为,使用内置 Android 资源会更好。
【讨论】: