我正在尝试将imageViews添加到线性布局中,如下所示:
LinearLayout.LayoutParams layoutParamsTV = new LinearLayout.LayoutParams(100, 100);
for( i = 0; i < 5; i++) {
LinearLayout llv = new LinearLayout(this);
llv.setOrientation(LinearLayout.VERTICAL);
ImageView row1 = new ImageView(this);
row1.getLayoutParams().height=50; // getting error here
}
如何设置ImageView的高度和宽度,我想在此imageView上再添加一个图像视图,该怎么做
答案 0 :(得分:1)
试试这个:
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(640, 480); // width , height
row1.setLayoutParams(params); // row1 is your ImageView