给图标右上角添加小图标

RelativeLayout.LayoutParams lp=(RelativeLayout.LayoutParams) new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.topMargin=-5;
lp.leftMargin=10;
lp.width=36;
lp.height=36;
RelativeLayout srcimg= (RelativeLayout) findViewById(R.id.relativeLayout1);//里面包含了一个图片

自适应显示
ImageView delimg=null;
delimg.setBackgroundResource(R.drawable.close);
// srcimg.addview(delimg,lp);
srcimg.addView(delimg, lp);

<RelativeLayout android:layout_width="wrap_content"
android:id="@+id/relativeLayout1" android:layout_height="wrap_content">
<ImageView android:layout_width="wrap_content"
android:id="@+id/imageView1" android:layout_height="wrap_content"
android:src="@drawable/icon"></ImageView>
</RelativeLayout>

猜你喜欢

转载自wshuanggang.iteye.com/blog/1664976