Có ai giải thích cho tôi biết tại sao điều này xảy ra không?Đệm không hoạt động với một số tài nguyên nền nhất định
Tôi có lớp TextView mở rộng khá đơn giản. Khi tôi thiết lập màu nền cho Color.BLUE, padding hoạt động tốt. Khi tôi thay đổi tài nguyên nền thành android.R.drawable.list_selector_background, phần đệm của tôi không còn được áp dụng nữa. Những gì các F?
Đây là lớp giao diện người dùng của tôi:
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);
}
}
Và tôi đang sử dụng nó trong cách bố trí như thế này:
<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"/>
Và đây là kết quả của việc thay đổi nền:
Thông tin thêm có thể được tìm thấy tại đây: http://stackoverflow.com/questions/2886140/does-changing-the-background-also-change-the-padding-of-a-linearlayout – TofferJ