2016-07-24 87 views
1

我正在使用以下鏈接創建自定義按鈕。我跟着每一步。 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"/> 

但我看到我的按鈕具有默認樣式。我期望我的按鈕具有這種新穎的定製風格。

回答

1

不要使用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

+0

我得到了,當我建立我的應用程序以下錯誤:錯誤:(11)未找到屬性資源標識符「風格'包'安卓' –

+0

然後,這個問題可能會幫助你: http://stackoverflow.com/questions/26070827/how-to-set-style-for-a-button-in-android –

+0

按鈕製造商鏈接部分幫助我解決了我的問題。 –