Android 在已有布局中动态添加控件
2013-08-01 15:44
465 查看
//手动添加imageview RelativeLayout mainLayout = (RelativeLayout)findViewById(R.id.relaGameZhaiGuoZi); imgApple2 = new ImageView(this); imgApple2.setImageResource(R.drawable.app); imgApple2.setId(110); //注意这点 设置id imgApple2.setOnClickListener(this); RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); // lp1.addRule(RelativeLayout.ALIGN_TOP); // lp1.setMargins(30, 50, 100, 100);//(int left, int top, int right, int bottom) lp1.leftMargin=30; lp1.topMargin = 100; mainLayout.addView(imgApple2,lp1);
相关文章推荐
- (Android开发)在已有布局中动态添加控件
- Android——在已有布局中动态添加控件
- Android中如何在“自定义布局”中“动态”添加控件
- android 在布局中动态添加控件
- Android动态添加设置布局与控件的方法
- Android 动态添加布局(layout)和控件(Widget)
- Android 在布局容器中动态添加控件
- 在已有布局中动态添加控件
- Android 中动态的向布局中添加控件
- 【Android动态布局】之【使用addView方法时,如何保持已有动态控件位置不被改变】
- Android初学习 - 在Java code(布局容器)中动态添加控件
- Android动态布局,并动态为TextView控件设置drawableLeft、drawableRight等属性添加图标
- Android动态布局,并动态为TextView控件设置drawableLeft、drawableRight等属性添加图标
- Android 动态添加线性布局(.java文件内) 实现控件按比例分割空间
- Android根据布局文件动态添加控件
- android 在布局中动态添加控件
- Android 在程序中动态添加 View 布局或控件
- Android开发学习笔记:为动态添加的Spinner控件绑定数据源以及监听事件
- 动态布局_01----动态添加控件 及 将某XML动态加入到Activity显示
- Android在程序中动态生成控件,动态布局