這裏是我的文字和圖像和文字視圖(i1,t1,t2)。我如何在我的類文件中動態地格式化這些視圖的寬度和高度。如何在這裏設置ImageView和TextView的寬度和高度?
ImageView i1 = new ImageView(this);
TextView t1 = new TextView(this);
TextView t2 = new TextView(this);
RelativeLayout rl1 = new RelativeLayout(this);
RelativeLayout.LayoutParams innerLP1 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
innerLP1.addRule(RelativeLayout.CENTER_IN_PARENT);
innerLP1.topMargin=(30);
t1.setText(name);
rl1.setLayoutParams(innerLP1);
rl1.addView(t1);
我已經在RelativeLayout rl1中添加了我的圖像和文字瀏覽。我應該再次創建另一個RelativeLayout,然後設置高度和寬度?我應該在哪裏設置文本和圖像大小的整數值? – Dext
對於文本大小tv.setTextSize(15);也可以是np。用這個。 –