Search code examples
androidtextviewshapesandroid-theme

How to change the shape of the Textview using themes and styles?


Is there any possible ways to change the shape of the TextView using themes and styles?

I have changed textview shape as rectangle but I failed to change the hexagonal shape of textview. How could I do this?

So far tried searching the web and tried the code, but got no solution for this.


Solution

  •     <?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>
    

    This is the resource file make in the res/values/red.xml and define this style in your textview like this.

    <?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>