2
A
回答
-1
shape.xml(保存在可繪製該文件)
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<stroke
android:width="1dp"
android:color="#000000"/> <!-- This is the Border Color For TextView-->
<!-- "#5D2E8C" -->
<solid android:color="#ffffff" /> <!-- background to the TextView -->
<padding
android:bottom="2dp"
android:left="2dp"
android:right="2dp"
android:top="2dp" />
<corners android:radius="20dp" />
</shape>
現在,設置背景屬性的TextView這樣的:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/shape"
/>
0
您可以創建背景用你最喜歡的圖像編輯器創建的圖像的9-patch
圖像(它應該很容易做到)或創建一個xml drawable。爲了在xml中創建這種類型的drawable,你可以使用ClipDrawable
,它會剪切另一個Shape
drawable。所以,你將有:
background.xml(這將是TextView
的背景):
<?xml version="1.0" encoding="utf-8"?>
<clip xmlns:android="http://schemas.android.com/apk/res/android"
android:clipOrientation="vertical"
android:drawable="@drawable/background_shape"
android:gravity="bottom" />
和background_shape.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<corners
android:bottomLeftRadius="15dp"
android:bottomRightRadius="15dp" />
<solid android:color="#ffffff" />
<padding
android:bottom="5dp"
android:left="7dp"
android:right="7dp" />
<stroke
android:width="2dp"
android:color="#000000" />
</shape>
然後在你的活動,你會得到該背景可繪製的那個TextView
,並設置其級別:
ClipDrawable clip = (ClipDrawable) findViewById(R.id.textView1).getBackground();
clip.setLevel(5000);
您可以通過彎道半徑,填充和ClipDrawable
的水平打柚木繪製的外觀。
我不知道你是否能夠用xml drawable獲得確切的圖像。
相關問題
- 1. 如何繪製一個閉合的彎曲形狀?
- 2. 繪製折線圖彎曲
- 3. 如何在Objective-C中繪製具有彎曲邊的形狀?
- 4. 創建矩形形狀可繪製的兩個側彎角在android
- 5. 彎曲的線條圖案
- 6. 從底部彎曲的矩形形狀
- 7. 彎曲圓形進度條
- 8. 用曲線繪製一條線
- 9. 在創建CSS彎曲三角形弧
- 10. NSBezierPath:創建一個「彎曲」方
- 11. 如何在表格的td內創建一條彎曲的線條?
- 12. 繪製形狀時線條被擦除
- 13. 帆布「隨機」彎曲的形狀
- 14. 如何創建一個曲線形狀(C)UISlider與目標C
- 15. 創建js克隆一個形狀與動態繪製圖形
- 16. 彎曲線形成圓形和橢圓
- 17. 用三條垂直線(條紋)創建一個形狀
- 18. 在grafana中繪製一條曲線
- 19. 龜彎曲線
- 20. 直線彎曲
- 21. 繪製一個Rosetta形狀
- 22. 繪製一條曲線連接,而不是一條直線
- 23. 沿着彎曲的UIBezierPath繪製漸變
- 24. HTML畫布 - 繪製彎曲的箭頭
- 25. 如何繪製彎曲邊界的右下角三角形?
- 26. iOS繪製帶彎曲末端的回形針
- 27. 多態形狀類繪製最近創建的任何形狀?
- 28. 的曲線形狀圖層繪製邊框
- 29. 繪製從LineShape繼承的新曲線形狀
- 30. 如何創建矩形背景,從一側稍微彎曲
你可以創建一個像這樣的9補丁程序,並可以將其設置爲你的textview的背景 – mudit 2012-07-16 09:50:08
這實際上是最簡單的方法,謝謝。 – FWeigl 2012-07-16 13:36:48
很高興幫助。 – mudit 2012-07-17 05:26:35