Kann mir jemand erklären, warum das passiert?Padding funktioniert nicht mit bestimmten Hintergrundressource
Ich habe eine ziemlich einfache Klasse TextView erweitern. Wenn ich die Hintergrundfarbe auf Color.BLUE einstelle, funktioniert Padding gut. Wenn ich die Hintergrundressource in android.R.drawable.list_selector_background ändere, wird mein Padding nicht länger angewendet. Was zum F?
Hier ist meine UI-Klasse:
public class GhostDropDownOption extends TextView {
TextView text_view;
public GhostDropDownOption(Context context, AttributeSet attrs) {
super(context, attrs);
setup(context);
}
public GhostDropDownOption(Context context) {
super(context);
setup(context);
}
private void setup(Context context) {
this.setClickable(false);
// THE 2 LINES BELOW ARE THE ONLY THING I'M CHANGING
//this.setBackgroundResource(android.R.drawable.list_selector_background);
this.setBackgroundColor(Color.BLUE);
}
}
Und ich bin es im Layout wie folgt aus:
<trioro.voyeur.ui.GhostDropDownOption
android:id="@+id/tv_dropdown_option_1"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="@string/request_control_dropdown_option_1"
android:textColor="#000000"
android:padding="10dip"/>
Und das ist das Ergebnis der Änderung des Hinter:
Weitere Informationen finden Sie hier: http://Stackoverflow.com/questions/2886140/does-changing-the-background-als-change-the-padding-of-a-linearlayout – TofferJ