我想在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 –