简体   繁体   中英

Ring shape android as TextView background

I want to dynamically create TextViews inside a circle background. I used this but top and bottom edges of the ring shape gets cut off.

<shape xmlns:android="http://schemas.android.com/apk/res/android"
   android:shape="ring">
<corners android:radius="10dip"/>
<stroke
    android:width="1dp"
    android:color="@color/blue_new"/>
<solid android:color="@android:color/transparent"/>

I use this as the background for my TextView

 <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/circle_keyword"
  /> 

Ring shape background gets cutoff. What am I doing wrong? Any clue will be appreciated.

I want to achieve something like this but Radius should be text size

在此处输入图片说明

Try this:-

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="oval">
<corners android:radius="10dip"/>
<stroke android:color="@color/red" android:width="2dip"/>
<solid android:color="@android:color/transparent"/>
</shape>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM