2016-05-10 14 views
0

ImageButtonの色を変更する必要があります。それは私がAPI 19と21で期待するように動作しますが、それより高いAPIでは21で動作しません。理由を理解できません。ここでセレクタがAPIの色を21以上に変更しない

は、セレクタのXMLです:

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:state_pressed="true"> 
     <shape android:shape="rectangle"> 
      <corners 
       android:radius="100dp" 
       /> 
      <solid 
       android:color="#427A53" 
       /> 
      <padding 
       android:bottom="0dp" 
       android:left="0dp" 
       android:right="0dp" 
       android:top="0dp" 
       /> 
      <size 
       android:width="60dp" 
       android:height="60dp" 
       /> 
     </shape> 
    </item> 
    <item> 
     <shape android:shape="rectangle"> 
      <corners 
       android:radius="100dp" 
       /> 
      <solid 
       android:color="#66bb6a" 
       /> 
      <padding 
       android:bottom="0dp" 
       android:left="0dp" 
       android:right="0dp" 
       android:top="0dp" 
       /> 
      <size 
       android:width="60dp" 
       android:height="60dp" 
       /> 
     </shape> 
    </item> 
</selector> 
+0

は答えとしてあなたのソリューションを投稿し、それを受け入れています。 ;)http://stackoverflow.com/help/self-answer –

答えて

0

SOLUTION

問題はのImageButtonのandroid:backgroundTint属性にあった、それは同じ色であり、それは、色の変化を "ブロッキング" されました。

0

bczセレクタあなたはこのように使用することができ、より高いバージョンのために、API 21より低い作業..

RippleDrawable rippleImgStart; 
final int ColorWhiteOpacity = Color.argb(75,255,255,255); 
imgStart = ContextCompat.getDrawable(this, R.drawable.start); 
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 
      rippleImgStart = new 
        RippleDrawable(ColorStateList.valueOf(ColorWhiteOpacity), imgStart, null); 
      btnselectvideo.setImageDrawable(rippleImgStart); 
} 
+0

ありがとう、私は少し簡単な方法で問題を解決しました。 – Arthur

+0

あなたのソリューションでは、あなたのイメージボタンの色だけを変更する..しかし、私のソリューションでも、リップルも提供することができます.. –

関連する問題