代码中设置View
来源:互联网 发布:麻瓜编程怎么样 编辑:程序博客网 时间:2024/06/05 12:03
layout = (FrameLayout) findViewById(R.id.framelayout); //移除所有的view //layout.removeAllViews(); //计算出屏幕的宽和高 int screen_w = getResources().getDisplayMetrics().widthPixels; int screen_h = getResources().getDisplayMetrics().heightPixels; image1 = new ImageView(Recycle.this); //设置View的属性 FrameLayout.LayoutParams params1 = new FrameLayout.LayoutParams(screen_w/2,screen_h/2); image1.setLayoutParams(params1); image1.setImageResource(R.mipmap.banner_a); layout.addView(image1); image2 = new ImageView(Recycle.this); FrameLayout.LayoutParams params2 = new FrameLayout.LayoutParams(screen_w/2,screen_h/2); params2.leftMargin = screen_w/8; image2.setLayoutParams(params2); image2.setImageResource(R.mipmap.banner_b); layout.addView(image2);
阅读全文
0 0
- 代码中设置View
- Android自定义View中代码设置style
- 在代码中设置view的宽
- 代码中给view设置背景
- 代码中设置View的LayoutParams
- 代码中动态设置view或布局的宽高
- 代码中设置view的大小和位置
- android在代码中设置View的属性
- 在storyboard或xib中,设置了View的约束,代码更改View的坐标大小
- 代码设置view的大小
- 关于代码动态设置view
- XML设置View的背景和代码中通过setBackground设置的背景尺寸不一
- android中如何在代码中直接设置View的layout_weight属性
- android中如何在代码中直接设置View的layout_weight属性
- android中如何在代码中直接设置View的layout_weight属性
- android中如何在代码中直接设置View的layout_weight属性
- android中如何在代码中直接设置View的layout_weight属性
- android中如何在代码中直接设置View的layout_weight属性
- Java基础知识总结一
- shell脚本基础知识
- 设计模式三(单例设计模式)
- STM32低功耗设计
- oracle-基本操作
- 代码中设置View
- Python创建目录文件夹
- 经典的图算法
- oracle查询语句优化
- (二)大型互联网分布式企业微服务云架构
- Android 头像修改 包含7.0
- Android Studio比较常用的插件
- Android中canvas.save()和canvas.restore()的使用
- $.get、$.post、$getJSON、$ajax的用法跟区别