是否可以将左边框分配给像我的附加图像那样具有左条形边框的图像?
我们需要将图像分配给 border 或者我们可以用 border image 来做? 任何人都可以帮忙吗?
提前致谢。
这是示例图片:
应用代码后的结果:
最佳答案
您可以通过以下方式轻松实现:
方法 1 - 您不想重叠图像的那一小部分:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<View
android:layout_width="8dp"
android:layout_height="match_parent"
android:background="#FF0000" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/my_image" />
</LinearLayout>
方法 2 - 您希望将图像与边框重叠的位置:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/my_image" />
<View
android:layout_width="8dp"
android:layout_height="match_parent"
android:background="#FF0000" />
</RelativeLayout>
关于android - 在android中为图像添加左边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33832714/