2011-12-08 25 views
6

düğmesine uygulandığında, creating custom buttons'da bir eğiticiyi takip ediyordum. Stili düğüme doğrudan uygularsam çalışır, ancak stili temaya android:buttonStyle kullanarak uygularsam işe yaramaz. -Tema olarak buttonStyle uygulanması işe yaramıyor, ancak doğrudan

bir örnek Burada uygulanan buton tarzı ile stil xml geçerli: değerler/styles.xml

<resources> 
    <style name="MyTheme" parent="android:Theme.Light"> 
     <!-- the button gets styled but is no longer clickable 
      if i do it like this --> 
     <item name="android:buttonStyle">@style/ButtonText</item> 
    </style> 

    <style name="ButtonText"> 
     <item name="android:layout_width">fill_parent</item> 
     <item name="android:layout_height">wrap_content</item> 
     <item name="android:textColor">#ffffff</item> 
     <item name="android:background">@drawable/ruddy_orange_button</item> 
    </style> 
</resources> 

çekilebilir/ruddy_orange_button.xml: Ben uygulamak Ancak

<item android:state_pressed="true"> 
     <shape> 
      <solid android:color="#70c656" /> 
      <stroke android:width="1dp" android:color="#53933f" /> 
      <corners android:radius="3dp" /> 
      <padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" /> 
     </shape> 
    </item> 
    <item> 
     <shape> 
      <gradient android:angle="270" android:endColor="#fd4d4d" android:startColor="#f24b4b" /> 
      <stroke android:width="1dp" android:color="#f04a4a" /> 
      <corners android:radius="4dp" /> 
      <padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" /> 
     </shape> 
    </item> 
</selector> 

doğrudan çalıştığı düğmeye: stil

Burada yaptığım şey hakkında herhangi bir işaretçi var mı?

Ben 2.3.3

Kaynak github üzerindedir Android'de bu test etti.

cevap

9

bu deneyin:

Ben de bu problem.hope vardı
<style name="ButtonText" parent="@android:style/Widget.Button"> 
6

ucu size

AppCompat V21 yardımcı olacaktır + Eğer tema buttonStyle yerine android:buttonStyle kullanmalıdır

İlgili konular