-1

I have a row of buttons each with numbers on them. I show which one is selected by changing the background, but one of these number would be the "current" number (kind of like a current date) and I want to indicate that it is the current one even when it is selected (since it will have the same background as all other selected ones) by adding a circle around the text

Kind of like this (with 23 being both selected and the current one): Example

I tried doing this by adding a radius to the button and adding padding but was having a bit of trouble, but even if it worked it feels like there is probably a better way.

How do I make the circle around the text in the button?

yitzih
  • 3,018
  • 3
  • 27
  • 44
  • Follow this [link](https://stackoverflow.com/questions/3882064/how-to-change-color-of-button-in-android-when-clicked?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa) for detailed explanation. – Prashant Abdare Apr 23 '18 at 04:11

1 Answers1

0
<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/num_txt"
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:layout_marginTop="0dp"
                android:background="@drawable/bg_red"
                android:gravity="center"
                android:text="My name is NON"
                android:textColor="#FFFFFF"
                android:textSize="10dp" />

        </RelativeLayout>

    </RelativeLayout>

bg_red.xml

 <?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="#FF0000" android:width="5dip"/>
        <solid android:color="#FF0000"/>
    </shape>

or try This or This

Developer
  • 333
  • 2
  • 16