动态添加ImageView 设置setPadding不起作用问题
imageView = new ImageView(NavigationActivity.this);
imageView.setLayoutParams(new LayoutParams(12,12));
imageView.setPadding(20, 0, 20, 0);
设置ImageView的setPadding(20, 0, 20, 0); 不起作用
改为
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(12, 12);
params.setMargins(0, 0,13, 0);
imageView = new ImageView(NavigationActivity.this);
imageView.setLayoutParams(params);
//////////////////////////////////////////////////////////////////////////////////////////////
private void init() {
// LinearLayout.LayoutParams用于控制两个点之间的距离
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(20,20);
params.setMargins(20, 0, 20, 0);
for (int i = 0; i < pageViews.size(); i++) {
imageView = new ImageView(InitStartActivity.this);
imageViews = imageView;
if (i == 0) {
//默认选中第一张图片
imageViews.setBackgroundResource(R.drawable.page_indicator_focused);
} else {
imageViews.setBackgroundResource(R.drawable.page_indicator);
}
// 指明某个ImageView需要左右隔开 20xp setPadding不起作用
group.addView(imageViews,params);
}
setContentView(main);
viewPager.setAdapter(new GuidePageAdapter());
viewPager.setOnPageChangeListener(new GuidePageChangeListener());
}
动态添加ImageView 设置setPadding不起作用问题的更多相关文章
- [转]jquery append 动态添加的元素事件on 不起作用的解决方案
用jquery添加新元素很容易,面对jquery append 动态添加的元素事件on 不起作用我们该如何解决呢?on方法中要先找到原选择器(如例.info),再找到动态添加的选择器(如列.delet ...
- jquery append 动态添加的元素事件on 不起作用的解决方案
用jquery添加新元素很容易,面对jquery append 动态添加的元素事件on 不起作用我们该如何解决呢?on方法中要先找到原选择器(如例.info),再找到动态添加的选择器(如列.delet ...
- android中,如果使用imageButton可以在drawable 中设置一个selector,但是imageView设置不起作用
android中,如果使用imageButton可以在drawable 中设置一个selector,但是imageView设置不起作用,只要把Imageview的src给去掉就成了,src捕获了bac ...
- 用jquery添加新元素很容易,面对jquery append 动态添加的元素事件on 不起作用我们该如何解决呢?
用jquery添加新元素很容易,面对jquery append 动态添加的元素事件on 不起作用我们该如何解决呢?on方法中要先找到原选择器(如例.info),再找到动态添加的选择器(如列.delet ...
- jq动态添加onclick事件在谷歌中不起作用
$("#oa-bed-rooType").append($('<option/>').val(0).text('请选择房间类型')); $('#oa-bed-roomT ...
- python 动态添加属性及方法及“__slots__的作用”
1.动态添加属性 class Person(object): def __init__(self, newName, newAge): self.name = newName self.age = n ...
- jquery append 动态添加的元素事件on 不起作用问题的解决
on方法中要先找到原选择器(如例.info),再找到动态添加的选择器(如列.delete). 不多说看成功代码(注意加粗加色): <!DOCTYPE html PUBLIC "-//W ...
- android动态添加TextView或者ImageView
动态添加 text1=new TextView(this); text1.setText("动态添加"); ((LinearLayout) this.findViewById(R. ...
- C#主菜单动态添加子菜单并设置触发事件
我所使用的是devxepress中的主菜单栏时barsubitem控件,想的是在其能够动态添加子菜单栏并能点击触发事件: /// <summary> /// 创建主按钮的子按钮 /// & ...
随机推荐
- hdu 5155(递推)
Harry And Magic Box Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- C#读取JSON字符串
下面这个是一段JSON字符串宏观图 下面我们通过C#读取JSON字符串里的任何一个数值 string jsonString="上面JSON字符串"; //需要引用Newtonsof ...
- Bfs+最短路【p3393】 逃离僵尸岛
Description 小a住的国家被僵尸侵略了!小a打算逃离到该国唯一的国际空港逃出这个国家. 该国有\(N\)个城市,城市之间有道路相连.一共有\(M\)条双向道路.保证没有自环和重边. \(K\ ...
- Palindrome Permutation -- LeetCode
Given a string, determine if a permutation of the string could form a palindrome. For example," ...
- Logger Rate Limiter -- LeetCode
Design a logger system that receive stream of messages along with its timestamps, each message shoul ...
- Reverse Words in a String II -- LeetCode
Given an input string, reverse the string word by word. A word is defined as a sequence of non-space ...
- Shader与AGAL(From 7yue)
- Winform打砖块游戏制作step by step第一节---主界面搭建
一 引子 为了让更多的编程初学者,轻松愉快地掌握面向对象的思考方法,对象继承和多态的妙用,故推出此系列随笔,还望大家多多支持. 二 本节内容---主界面搭建 1.主界面截图 2. 该窗体主要包含了以下 ...
- DEV MarqueeProgressBarControl控件
原文地址:http://www.dobug.net/showtopic-672.html MarqueeProgressBarControl是DevExpress的一个进度条控件,该控件和Progre ...
- C和C++中函数运行时间测试
//clock()函数为c中,捕捉从程序开始运行到clock运行的时间//时间单位为clock tick,即为时钟打点#include<iostream>#include<cmath ...