任何人都可以向我解釋爲什麼會發生這種情況嗎?填充不適用於某些背景資源
我有一個相當簡單的類擴展TextView。當我將背景色設置爲Color.BLUE時,填充效果很好。當我將背景資源更改爲android.R.drawable.list_selector_background時,我的填充不再適用。什麼是F?
這裏是我的UI類:
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);
}
}
而且我使用它在像這樣的佈局:
<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"/>
這是改變背景的結果:
更多信息可以在這裏找到:http://stackoverflow.com/questions/2886140/does-changing-the-background-also-change-the-padding-of-a-linearlayout – TofferJ