ViewGroup

xml

    <LinearLayout
        android:id="@+id/ln_Group"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/bt_addImg"
        android:layout_alignLeft="@+id/et_exp"
        android:layout_alignTop="@+id/bt_addImg"
        android:orientation="horizontal" >

    </LinearLayout>

.java 添加三张图片

private ViewGroup mgroup;
mgroup=(ViewGroup)findViewById(R.id.ln_Group);
        ImageView imageView;
        LayoutParams params = new LayoutParams(80,
                80);
        int[] ids = { R.drawable.pic1, R.drawable.pic2, R.drawable.pic3 };
        for (int i = 0; i < ids.length; i++) {
            imageView = new ImageView(AddExpActivity.this);
            imageView.setImageResource(ids[i]);
            imageView.setLayoutParams(params);
            imageView.setScaleType(ScaleType.FIT_XY);
        mgroup.addView(imageView);
        }

 

 

Done

 

posted @ 2014-05-22 20:48  行云有影  阅读(192)  评论(0编辑  收藏  举报