布局奇怪的效果?!效果
这是奇怪的图片
下面是代码
RelativeLayout mvLine = new RelativeLayout(this.getBaseContext());
mvLine.setClickable(true);
mvLine.setOnClickListener(detailListener);
mvLine.setBackgroundDrawable(this.getBaseContext()
.getResources().getDrawable(R.drawable.list_bg));
//mvLine.setOrientation(android.widget.LinearLayout.HORIZONTAL); ImageView img = new ImageView(this.getBaseContext());
img.setImageDrawable(this.getBaseContext().getResources()
.getDrawable(R.drawable.loading_img));
img.setPadding(21, 3, 0, 4); ImageLoader.getInstance().loadImage(
hotmvs.item(i).getAttributes().getNamedItem("subimg")
.getNodeValue(), img, R.drawable.load_err_img); mvLine.addView(img, ViewGroup.MarginLayoutParams.WRAP_CONTENT,
ViewGroup.MarginLayoutParams.WRAP_CONTENT); LinearLayout ll = new LinearLayout(this.getBaseContext());
ll.setOrientation(ll.VERTICAL); // name
TextView text = new TextView(this.getBaseContext());
text.setText("名称:"
+ hotmvs.item(i).getAttributes()
.getNamedItem("subname").getNodeValue());
// 前两位是透明度
text.setTextColor(0xff000000);
text.setTextSize(16);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp.topMargin = 17;
lp.leftMargin = 12;
ll.addView(text, lp); TextView text2 = new TextView(this.getBaseContext());
text2.setText("看点:"
+ hotmvs.item(i).getAttributes()
.getNamedItem("subname").getNodeValue()); LinearLayout.LayoutParams lp2 = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp2.topMargin = 2;
lp2.leftMargin = 12;
ll.addView(text2, lp2);
mvLine.addView(ll, ViewGroup.MarginLayoutParams.FILL_PARENT,
ViewGroup.MarginLayoutParams.FILL_PARENT); EditText et = new EditText(this.getBaseContext());
et.setText(hotmvs.item(i).getAttributes().getNamedItem(
"contenturl").getNodeValue());
et.setVisibility(EditText.GONE);
mvLine.addView(et, ViewGroup.MarginLayoutParams.WRAP_CONTENT,
ViewGroup.MarginLayoutParams.WRAP_CONTENT); ImageButton ib = new ImageButton(this.getBaseContext());
ib.setBackgroundDrawable(this.getResources().getDrawable(
R.drawable.arrow));
这是奇怪的图片
下面是代码
RelativeLayout mvLine = new RelativeLayout(this.getBaseContext());
mvLine.setClickable(true);
mvLine.setOnClickListener(detailListener);
mvLine.setBackgroundDrawable(this.getBaseContext()
.getResources().getDrawable(R.drawable.list_bg));
//mvLine.setOrientation(android.widget.LinearLayout.HORIZONTAL); ImageView img = new ImageView(this.getBaseContext());
img.setImageDrawable(this.getBaseContext().getResources()
.getDrawable(R.drawable.loading_img));
img.setPadding(21, 3, 0, 4); ImageLoader.getInstance().loadImage(
hotmvs.item(i).getAttributes().getNamedItem("subimg")
.getNodeValue(), img, R.drawable.load_err_img); mvLine.addView(img, ViewGroup.MarginLayoutParams.WRAP_CONTENT,
ViewGroup.MarginLayoutParams.WRAP_CONTENT); LinearLayout ll = new LinearLayout(this.getBaseContext());
ll.setOrientation(ll.VERTICAL); // name
TextView text = new TextView(this.getBaseContext());
text.setText("名称:"
+ hotmvs.item(i).getAttributes()
.getNamedItem("subname").getNodeValue());
// 前两位是透明度
text.setTextColor(0xff000000);
text.setTextSize(16);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp.topMargin = 17;
lp.leftMargin = 12;
ll.addView(text, lp); TextView text2 = new TextView(this.getBaseContext());
text2.setText("看点:"
+ hotmvs.item(i).getAttributes()
.getNamedItem("subname").getNodeValue()); LinearLayout.LayoutParams lp2 = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp2.topMargin = 2;
lp2.leftMargin = 12;
ll.addView(text2, lp2);
mvLine.addView(ll, ViewGroup.MarginLayoutParams.FILL_PARENT,
ViewGroup.MarginLayoutParams.FILL_PARENT); EditText et = new EditText(this.getBaseContext());
et.setText(hotmvs.item(i).getAttributes().getNamedItem(
"contenturl").getNodeValue());
et.setVisibility(EditText.GONE);
mvLine.addView(et, ViewGroup.MarginLayoutParams.WRAP_CONTENT,
ViewGroup.MarginLayoutParams.WRAP_CONTENT); ImageButton ib = new ImageButton(this.getBaseContext());
ib.setBackgroundDrawable(this.getResources().getDrawable(
R.drawable.arrow));
解决方案 »
- arcgis for android 路径绘制
- AndEngine连demo都跑不起来求助
- 用Cursor和ContentResolver删除指定的联系人
- getSharedPreferences会不会有脏读行为产生??
- android 三维空间效果
- 如何响应按键来关闭WindowManger生成的FloatView
- android 黑白棋对战----项目在线咨询------大牛们帮帮忙
- 用ImageSpan实现输入框种插入图片的问题
- 关于listview分割线的问题
- 装完SDK然后发现system image文件夹有12G
- log如何指定打印到哪个buffer?
- 布局奇怪的效果?!各位能帮忙看看吗?
private static final int ID_IMG = 1;
2.设置image的id
img.setId(ID_IMG);
3.设置线性布局的layout
RelativeLayout.LayoutParams lp3 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lp3.addRule(RelativeLayout.ALIGN_TOP, ID_IMG);
lp3.addRule(RelativeLayout.RIGHT_OF , ID_IMG);
mvLine.addView(ll, lp3);