- I am trying a display a single letter on a
TextView. - Here
TextViewis having abackground drawablewith a border butTextViewexpands and shrinks based on that single letter and I don't want that.
My layout code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="4dp">
<TextView
android:id="@+id/txt_letter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/drawable_bg"
android:fontFamily="@font/viga"
android:padding="@dimen/padding_16dp"
android:text="A"
android:textAppearance="@style/TextAppearance.AppCompat.Title" />
drawable_bg.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#F5F5F5" />
<stroke
android:width="1dp"
android:color="#9E9E9E" />
<corners android:radius="4dp" />
<padding
android:bottom="8dp"
android:left="20dp"
android:right="20dp"
android:top="8dp" />
</shape>

You're using
wrap_contentso the size is change according to the text. Simply use fixed dimension