2016-09-20 2 views
0

誰がスタイルのボタンで私を助けることができますか?どのようにボタンのスタイルを変更する必要があります、私は角度に問題がない、私は、なぜ私はボタンのデフォルトのスタイルを持っています。 これは私のコードと表示問題ボタンのスタイルのAndroid

Angels1

Angles2

Button style="@style/gradient_button" 

スタイルです - gradient_button

<style name="button_common"> 
<item name="android:layout_height">wrap_content</item> 
<item name="android:layout_width">wrap_content</item> 
<item name="android:textColor">#ffffff</item> 
<item name="android:textSize">14sp</item> 
</style> 
    <style name="gradient_button" parent="@style/button_common"> 
     <item name="android:background">@drawable/button_grad</item> 
    </style> 

とファイルbutton_grad

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item 
     android:state_enabled="true" 
     android:state_pressed="false" 
     android:drawable="@drawable/b59" /> 
    <item 
     android:state_enabled="true" 
     android:state_pressed="true" 
     android:drawable="@drawable/y59" /> 
    <item 
     android:state_enabled="false" 
     android:drawable="@drawable/b59" /> 
</selector> 

b59とy59これらは9パッチの画像です。

答えて

0

あなたのアングルの問題については、あなたの画像や約9パッチに関するエラーです。

あなたが描画可能なフォルダ内のボタンのスタイルを書くことができます。

style_button.xml :あなたの描画可能なフォルダに

<style name="button_common"> 
<item name="android:layout_height">wrap_content</item> 
<item name="android:layout_width">wrap_content</item> 
<item name="android:textColor">#ffffff</item> 
<item name="android:textSize">14sp</item> 
</style> 

selector.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item 
     android:state_enabled="true" 
     android:state_pressed="false" 
     android:drawable="@drawable/b59" /> 
    <item 
     android:state_enabled="true" 
     android:state_pressed="true" 
     android:drawable="@drawable/y59" /> 
    <item 
     android:state_enabled="false" 
     android:drawable="@drawable/b59" /> 
</selector> 

ボタンにそのスタイルを適用:

<Button 
       android:id="@+id/btn" 
       style="@style/style_button" 
       android:layout_centerVertical="true" 
       android:background="@drawable/selector" 
       android:drawablePadding="10dp" 
       android:text="btnText" /> 
+0

私は試みましたが、まだ天使に問題がありました。あなたは写真1と2で見ることができます、私は分かりません。たぶんそれは問題の背景のデフォルトボタン(素材デザイン) –

+0

おそらく問題はあなたの画像と約9パッチについてです – Carlo

+0

ああ、私は、確信していると思います。ありがとう –

関連する問題