Wie ändere ich die Farbe für Android: DractableStart?

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Wie ändere ich die Farbe für Android: DractableStart?

by Anonymous » 14 Feb 2025, 11:32

Ich habe eine einfache Taste mit einem zeichnbaren links: < /p>

Code: Select all

< /code>
Um die zeichnbare Farbe zu ändern, verwende ich diesen Code: < /p>
public void setColorOnButton( int id, int color){
Button btn = findViewById( id );
for( Drawable drawable : btn.getCompoundDrawables()) {
if( drawable != null){
drawable.setColorFilter(new PorterDuffColorFilter( 0xff000000|color, PorterDuff.Mode.SRC_IN));
}
}
}
Es funktioniert gut. Code> und setColoronButton funktioniert nicht: btn.getCompoundDrawables () Nulls zurückgeben.
Was ist falsch?

Top