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的位置. ...
随机推荐
- 股票技术指标中的VOL,KDJ,MACD,OBV,VR,DMA分别代表什么意思?很关键,谢谢
http://zhidao.baidu.com/link?url=glKK7n0JUgqgrvfx2Gzd937-5zZg1bC615MwAp0P_mrYDytnMUpjoOQgYU871ny8St1 ...
- ubuntu 安装 phpstorm
phpstorm是用JAVA开发的,所以在安装之前需要先安装jdksudo apt-get install default-jdk从官网上下载phpstorm 的linux版本 http://www. ...
- POJ - 3414 Pots 【BFS】
题目链接 http://poj.org/problem?id=3414 题意 给出两个杯子 容量分别为 A B 然后给出C 是目标容量 有三种操作 1 将一个杯子装满 2.将一个杯子全都倒掉 3.将一 ...
- 【leetcode刷题笔记】Implement strStr()
Implement strStr(). Returns a pointer to the first occurrence of needle in haystack, or null if need ...
- 20145210姚思羽《网络对抗》——shellcode注入& Return-to-libc攻击深入
20145210姚思羽<网络对抗>shellcode注入&Return-to-libc攻击深入 shellcode基础知识 Shellcode是一段代码,作为数据发送给受攻击服务器 ...
- 20165101刘天野 2018-2019-2《网络对抗技术》Exp8 Web基础
20165101刘天野 2018-2019-2<网络对抗技术>Exp8 Web基础 1.实验内容 1.1 Web前端HTML (1)输入命令service apache2 start启动A ...
- 微信等webview中无法修改document.title的情况
// hack在微信等webview中无法修改document.title的情况 var $iframe = $('<iframe src="https://www.bbtree.co ...
- java:练习超市卖场
java:练习超市卖场 涉及到:大商品类,具体商品(以书为例),卖场类 Goods,Book,superMart, 商品类Goods: public interface Goods { //商品类 ...
- hdu 1503 Advanced Fruits(最长公共子序列)
Advanced Fruits Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- windows下安装 postgresql
1. 下载PostgreSQL的源代码.解压. 2. 在Windows平台下编译需要跳过一个权限的检测,否则在编译的时候可能会出现错误. 在\src\backend\main\main.c文件中将 ...