0
是否有任何可能的方法來改變使用主題和樣式的TextView的形狀?如何使用主題和樣式更改Textview的形狀?
我已將textview形狀更改爲矩形,但未能更改textview的六角形形狀。我怎麼能這樣做?
到目前爲止,已經嘗試搜索網絡並嘗試了代碼,但沒有得到解決。
是否有任何可能的方法來改變使用主題和樣式的TextView的形狀?如何使用主題和樣式更改Textview的形狀?
我已將textview形狀更改爲矩形,但未能更改textview的六角形形狀。我怎麼能這樣做?
到目前爲止,已經嘗試搜索網絡並嘗試了代碼,但沒有得到解決。
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="black_text_view_medium" parent="@android:style/TextAppearance.Medium">
<item name="android:textColor">@color/black</item>
<item name="android:typeface">normal</item>
<item name="android:textSize">16sp</item>
</style>
</resources>
這是在res/values/red.xml中創建的資源文件,並在您的textview中像這樣定義此樣式。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
style="@style/black_text_view_medium"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is your Textview Style"
/>
</LinearLayout>
試試這個代碼,
shape.xml(保存此在res /抽拉/)
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<corners android:radius="3dp/>
</shape>
</item>
</selector>
然後改變的TextView的背景。
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/shape" />