我想在textview上放一个圆圈背景。渲染时,圆形变成椭圆形。Android圈背景变成椭圆形
我的布局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>
我的圈子背景:
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid
android:color="#79bfea"/>
</shape>
您应该设置layout_weight和layout_height固定值,我认为。下面的@ sudhasri的解决方案不起作用? –
我做到了这一点,我通过扩展TextView来设置宽度为高度也覆盖onMeasure –