new LayoutParams 使用
ImageView imageView = new ImageView(mcontext);
LayoutParams layoutParams = new LayoutParams(150,130);
layoutParams.leftMargin=20;
// layoutParams.leftMargin
imageView.setLayoutParams(layoutParams); //添加view 到layout
imageView.setScaleType(ScaleType.FIT_XY);
imageView.setBackgroundResource(R.drawable.shape_border_img);
ImageLoader.getInstance().displayImage(productslist.get(i).getPimg(), imageView);
viewHolder.product_img_lin.addView(imageView); // layout加上imageview
第二种 :
// 创建LinearLayout
LinearLayout linearLayout = new LinearLayout(this);
linearLayout.setOrientation(LinearLayout.VERTICAL);
linearLayout.setLayoutParams(new LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
// Creates a new ImageView
ImageView imageView = new ImageView(this);
// Sets the bitmap for the ImageView from an icon bit map (defined
// elsewhere)
imageView.setImageResource(R.drawable.play);
// 或者通过名字来获取,int id = getResources().getIdentifier("gameover",
// "drawable", getPackageName());
int id = getResources().getIdentifier("play", "drawable",
getPackageName());
imageView.setImageResource(id);
// setting image position
imageView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
// Sets the tag
imageView.setTag(IMAGEVIEW_TAG);
// adding view to layout
linearLayout.addView(imageView);
// make visible to program
setContentView(linearLayout);
new LayoutParams 使用的更多相关文章
- WindowManager.LayoutParams 札记
WindowManager.LayoutParams wlp = new WindowManager.LayoutParams(width, height, WindowManager.LayoutP ...
- [Android] 转-LayoutInflater丢失View的LayoutParams
原文地址:http://lmbj.net/blog/layoutinflater-and-layoutparams/ View view = inflater.inflate(R.layout.ite ...
- 安卓冷知识:LayoutParams
安卓的布局有很多种,每种都有对应的LayoutParams类,那么它们之间到底是什么关系? 为什么在编写Layout的XML文件时,有的layout_前缀属性有用有的没有用? 一句话道出LayoutP ...
- 通过inflate获取布局,设置layoutparams无效
给ll——addtiem当设置layoutparams无效时,试着修改上一个布局的属性
- ListView的LayoutParams设置
// Temp is the root view that was found in the xml final View temp = createViewFromTag(root, name, a ...
- Android LayoutParams简介
LayoutParams是子控件控制自己在父控件中布局的一个类. 不同布局都有相对的LayoutParams,最简单的LinearLayout.LayoutParams类可以设置布局的宽高. 我在写一 ...
- 简单研究Android View绘制二 LayoutParams
2015-07-28 17:23:20 本篇是关于LayoutParams相关 ViewGroup.LayoutParams文档解释如下: LayoutParams are used by views ...
- RelativeLayout.LayoutParams.addRule()方法
1.应用场景 在使用RelativeLayout布局的时候,通常在载入布局之前在相关的XML文件中进行静态设置即可.但是,在有些情况下,我们需要动态的设置布局 的属性,在不同条件下设置不同的布局排列方 ...
- android中的layoutparams参数使用的简单总结
定义: 我们可以在Android的framework中的ViewGroup类里找到定义的类: public static class LayoutParams{...} 此类有如下注释: Layout ...
- LayoutParams使用
LayoutParams继承于Android.View.ViewGroup.LayoutParams. LayoutParams相当于一个Layout的信息包,它封装了Layout的位置. ...
随机推荐
- 导入android sdk samples工程报错"did you mean to use @+id instead of @+android:id?"
导入“D:\adt-bundle-windows-x86_64-20140702\sdk\samples\android-15”中的工程报错 did you mean to use @+id inst ...
- Elasticsearch的几种架构(ELK,EL,EF)性能对比测试报告
Elasticsearch的几种架构性能对比测试报告 1.前言 选定了Elasticsearch作为存储的数据库,但是还需要对Elasticsearch的基础架构做一定测试,所以,将研究测试报告输出如 ...
- Data Structure Linked List: Reverse a Linked List in groups of given size
http://www.geeksforgeeks.org/reverse-a-list-in-groups-of-given-size/ #include <iostream> #incl ...
- 运行vo总结
这是基于之前的vo类做的.vo类总结.note参数文件的直接设置在config目录下,比如是default.yaml文件,里面会定义dataset_dir,cmera类的fx,fy,cx,cy,Vis ...
- LINQ 学习路程 -- 查询操作 Distinct Except Intersect Union
Set Operators Usage Distinct 去掉集合的重复项 Except 返回两个集合的不同,第一个集合的元素不能出现在第二个集合中 Intersect 返回两个集合的交集,即元素同时 ...
- TF卡
1.我的手机 64G 2.冬冬手机 16G 3.茜茜收音机 8G(创见) 4.父 手机 8G(Kingston) 5. 6. 7.
- kreuz-frankfurt-sample-generic-2019-02-08.xodr文件解读
第1行:xml语法所遵循的版本. L2:文件封装标记. L3:Opendrive的主要修订编号 次要修订编号 供应商. L4:记录有关地理参考坐标系的参数,投影-横轴墨卡托 a-地球椭球长半 ...
- mysql 如何创建索引
mysql 如何创建索引 一.总结 一句话总结:MySQL中可以使用alter table这个SQL语句来为表中的字段添加索引. 使用alter table语句来为表中的字段添加索引的基本语法是:AL ...
- 分享知识-快乐自己:Struts2 (常用的 constant 总结)
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-/ ...
- [原创]Java开发在线编辑Word同时实现全文检索
一.背景介绍 Word文档与日常办公密不可分,在实际应用中,当某一文档服务器中有很多Word文档,假如有成千上万个文档时,用户查找打开包含某些指定关键字的文档就变得很困难,一般情况下能想到的解决方案是 ...