テーマとスタイルを使用して TextView の形状を変更する方法はありますか?
テキストビューの形状を長方形に変更しましたが、テキストビューの六角形の形状を変更できませんでした。どうすればこれを行うことができますか?
これまでのところ、Web を検索してコードを試してみましたが、これに対する解決策はありませんでした。
テーマとスタイルを使用して TextView の形状を変更する方法はありますか?
テキストビューの形状を長方形に変更しましたが、テキストビューの六角形の形状を変更できませんでした。どうすればこれを行うことができますか?
これまでのところ、Web を検索してコードを試してみましたが、これに対する解決策はありませんでした。
このコードを試して、
shape.xml ( res/drawable/ に保存)
<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" />
<?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>