我想要一个只有边框的图像视图,它内部是透明的。获取边框的常用技巧似乎是使用另一个imageview,稍微大一点的大小就在imageView的下方,在这里工作,因为我想要一个透明的imageview。 我如何创建它?在android中的透明imageView的边框
4
A
回答
11
在绘制文件夹
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="@color/transparent" />
<stroke
android:width="0.5dip"
android:color="@color/black" />
<padding
android:bottom="2dp"
android:left="2dp"
android:right="2dp"
android:top="2dp" />
</shape>
创建一个新的文件backgroundcolor.xml并为背景添加到您的ImageView
0
您可以使用XML文件作为一个ImageView的可拉伸性。例如,把这个XML文件作为border.xml在绘制-MDPI文件夹:
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF" />
<stroke android:width="1dp" android:color="#000000" />
<padding android:left="1dp" android:top="1dp" android:right="1dp"
android:bottom="1dp" />
</shape>
,然后在主布局,用它作为一个ImageView的背景绘制。 imageview将是空的,只有边框将被显示。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="100dp"
android:src="@drawable/border" />
</LinearLayout>
相关问题
- 1. ImageView透明设置边缘/边框Android
- 2. 透明度在边框右边的CSS
- 3. JTextField在Swing中的透明边框
- 4. 透明边框内
- 5. Android的imageview边框填充
- 6. ImageView中的透明位图
- 7. Android:如何使位图边框透明?
- 8. android中的Custon对话框 - 没有边框和透明BG
- 9. 淡入淡出ImageView边缘到透明
- 10. 在ImageView中的不透明图像上的透明图像
- 11. Chrome中的透明圆角边框
- 12. Safari中的透明圆形边框
- 13. 在android中的透明对话框
- 14. 边框透明按钮
- 15. 透明边框是白色
- 16. 透明边框编程
- 17. Qt风格 - 透明边框
- 18. CSS透明表格边框
- 19. UIButton半透明边框
- 20. 完全透明边框
- 21. 边框不透明渐变
- 22. 在Android上的半透明形状上绘制顶部边框
- 23. ImageView的透明视图
- 24. 如何为透视效果制作边框的透明边角?
- 25. 基于CSS的50%透明边框不使用透明图像
- 26. 围绕盒子的玻璃(不透明/透明)边框?
- 27. 带不透明边框的半透明背景色
- 28. 使边框不透明,如果div是透明的
- 29. 不透明的OpenGL纹理有透明边框
- 30. Imageview背景透明