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