android上的自定义按钮样式
问题描述:
我正在使用以下链接创建自定义按钮。我跟着每一步。 https://androidcookbook.com/Recipe.seam?recipeId=3307android上的自定义按钮样式
然后,我创建了一个按钮,通过以下方式:
<Button
android:id="@+id/btnButton1"
android:layout_width="95dp"
android:layout_height="wrap_content"
android:buttonStyle="@style/button"
android:text="CREATE"
android:onClick="createButtonClickHandler"/>
但我看到我的按钮具有默认样式。我期望我的按钮具有这种新颖的定制风格。
答
不要使用buttonStyle
,只使用style
:
<Button
android:id="@+id/btnButton1"
android:layout_width="95dp"
android:layout_height="wrap_content"
android:style="@style/button"
android:text="CREATE"
android:onClick="createButtonClickHandler"/>
参考:https://developer.android.com/guide/topics/ui/themes.html
我得到了,当我建立我的应用程序以下错误:错误:(11)未找到属性资源标识符“风格'包'安卓' –
然后,这个问题可能会帮助你: http://stackoverflow.com/questions/26070827/how-to-set-style-for-a-button-in-android –
按钮制造商链接部分帮助我解决了我的问题。 –