I found this answer, which makes sure the aspect ratio is preserved of the an ImageView
.
How would I be able to do that with a TextView
with a background drawable? I have this TextView
:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:padding="5dp"
android:layout_margin="5dp"
android:text="1"
android:textColor="@color/white"
android:id="@+id/tvCount"
android:background="@drawable/textview_notify"
android:layout_column="2"
android:layout_gravity="right|top"/>
and this is my background drawable:
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
>
<!-- The fill color -->
<solid android:color="@color/red" />
<!-- Just to add a border -->
<stroke
android:color="@color/white"
android:width="2dp"
/>
</shape>
How to make sure the TextView
stays square (and the background thus a perfect circle?).