是否可以在不使用框架布局+任何不必要的嵌套的情况下在 ImageView 中显示多个可绘制对象(它们之间有边距)?如何实现以下目标?
drawableA
与drawableB
有上月底/右10dp保证金XML
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/myImgView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/myTxtView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
爪哇
Resources r = getContext().getResources();
int tenDp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, r.getDisplayMetrics());
ImageView customIV = content.findViewById(R.id.myImgView);
Drawable drawableA = getResources().getDrawable(R.drawable.ic_happyface);
Drawable drawableB = getResources().getDrawable(R.drawable.ic_neutralface);
Drawable drawableC = getResources().getDrawable(R.drawable.ic_sadface);
customIV.addView(?);
一个ImageView
只有一个Drawable
。多重ImageViews
需要显示多Drawable
秒。
您可以LinearLayout
用 a替换根RelativeLayout
以避免嵌套。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句