-1
我在玩Android的TextView對象的背景圖像,我想知道高度的奇怪行爲。Android:TextView背景可繪製 - 允許高度爲0?
爲什麼我無法將TextView的高度設置爲0,因此它變得「不可見」,並且不再佔用任何空間 - 設置背景圖像時?
下面是一些測試代碼,演示了 - 對我來說 - 奇怪的行爲。
public class HelloAndroid extends Activity implements View.OnClickListener{
TextView btn;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
btn = new TextView(this);
btn.setOnClickListener(this);
//Put in any drawable of you in here
btn.setBackgroundDrawable(getResources().getDrawable(R.drawable.restablebg5));
btn.setHeight(80);
LinearLayout v = new LinearLayout(this);
v.setOrientation(LinearLayout.VERTICAL);
v.addView(btn);
setContentView(v);
}
public void onClick(View arg0) {
btn.setHeight(0);
}
}
我如何設置的TextView爲0的高度?
感謝