布局奇怪的效果?!效果
这是奇怪的图片
下面是代码
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));
解决方案 »
- 关于FragmentActivity的问题
- adnroid上如何访问url返回数据,特殊!!
- 使用Application类共享数据的问题
- 请问 onActivityResult只能顺利触发一次是什么原因?
- 想学习Android,请教有什么菜鸟看的基础入门的书或资料
- 摩托罗拉非原生安卓系统2次开发
- Android 可以连接其他类型数据库吗?
- Service类中如何在覆写的onStart方法中调用Toast,要求Toast能实现显示图片和文字
- 急求助!!MAC 10.10版本搭建安卓开发环境
- 安卓问题 照着第一行代码敲的 第14章天气app实战 在点击listview的item时 一直等待出不来结果
- 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);