0
A
回答
1
定义图像视图,并为背景定义矩形形状。
<ImageView
android:id="@+id/image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/rectangle"
android:src="@drawable/ic_launcher" />
该矩形定义如下。
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@android:color/white" />
<size
android:width="100dp"
android:height="100dp" />
<stroke
android:width="10dp"
android:color="@android:color/black" />
<corners android:radius="50dp"/>
</shape>
最后,从代码,设置颜色这种方式:
ImageView image = (ImageView) findViewById(R.id.image);
GradientDrawable background = (GradientDrawable) image.getBackground();
background.setStroke(10, getResources().getColor(android.R.color.black));
相关问题
- 1. C#创建日志系统
- 2. uimaFIT创建类型系统
- 3. 创建附加系统
- 4. 创建操作系统
- 5. OGRE - 创建粒子系统
- 6. 创建信息系统图
- 7. 创建队列系统
- 8. 如何让android构建系统来创建jar文件?
- 9. alertbox android系统
- 10. 在android系统
- 11. android系统
- 12. 在android系统
- 13. 在android系统
- 14. 让android系统
- 15. 在android系统
- 16. android系统
- 17. android系统
- 18. 在android系统
- 19. android系统
- 20. android系统
- 21. android系统
- 22. android系统
- 23. android系统
- 24. android系统
- 25. android系统
- 26. android系统
- 27. android系统
- 28. android系统xamarin
- 29. NoSuchMethodException android系统
- 30. 在android系统
联合[此](https://github.com/MostafaGazar/CustomShapeImageView)用的形状。 – 2015-03-02 14:06:03
这可以帮助您在运行时绘制和更改Stoke颜色。 [1]:http://stackoverflow.com/questions/13585496/change-shape-border-color-at-runtime – Hanan 2015-03-02 14:06:18