Android圆圈背景变为椭圆形 [英] Android circle background becomes oval

查看:152
本文介绍了Android圆圈背景变为椭圆形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在textview上放置一个圆圈背景.渲染后,该圆变为椭圆形.

I want to put a circle background on a textview. The circle becomes oval when its rendered.

我的布局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>

推荐答案

  • 将您的textViewlayout_heightlayout_width更改为wrap_content
  • 在形状标签内添加尺寸标签,如下所示:
    • Change your textView's layout_height and layout_width to wrap_content
    • Add size tag inside shape tag as follows
    • <shape 
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:shape="oval">> 
      <solid android:color="#79bfea" />
      <size android:height="25dp"
         android:width="25dp"/>
      </shape>
      

      如果它仍然是椭圆形,请尝试增加size标签的宽度和高度.它对我有用!

      If it is still oval, try increasing the width and height in size tag. It worked for me!

      这篇关于Android圆圈背景变为椭圆形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆