Chcę umieścić tło okręgu w widoku tekstowym. Okrąg staje się owalny, gdy jest renderowany.Tło kółka Androida staje się owalne.
Mój układ XML:
<TextView
android:id="@+id/amount_key"
android:layout_weight="1"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_marginRight="2dp"
android:gravity="center"
android:background="@drawable/circle"
android:layout_marginLeft="20dp"
android:text="3\ndays"
android:padding="20dp"
android:textColor="#ffffff"
android:textStyle="bold"
android:textSize="25dp" />
</LinearLayout>
Mój krąg tła:
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid
android:color="#79bfea"/>
</shape>
Należy ustawić layout_weight i layout_height do stałej wartości, myślę. @ Rozwiązanie sudhasri poniżej nie działa? –
Zrobiłem to, i nadpisałem onMeasure, rozszerzając TextView, aby ustawić szerokość jako wysokość również –