0

Can someone please guide me how exactly can i create a circular buttons and textview in android apps, I am still a new into android development. Please help

Manoj Kumar
  • 11
  • 1
  • 3
  • 6

2 Answers2

4

You cannot create a real circular view (button or textview) in android - all views are rectangular. That said, you can imitate the look of a circular button by giving it a circular background. There are several ways of doing this. One simple way would be to create a PNG image of a circle, save it in your drawable folder and then set it as a background for your button:

<Button android:background="@drawable/circle_bg" .../>

Another way would be to use custom shapes to draw a circle:

<shape android:shape="oval" ...>
    <solid android:color="#FFFFFF"/>
</shape>

Save that as an XML file in your drawable as circle.xml and then reference it in your layout:

<Button android:layout_width="40dp" layout_height="40dp"
        android:background="@drawable/circle" ... />

This will create a circular button with 20dp radius.

Of course, you may want to combine this with state selectors to get the highlighted states on touch or focus.

There are loads of examples on the internet. Just search.

Aleks G
  • 56,435
  • 29
  • 168
  • 265
0

As some1 mentioned, to make your custom buttons you've to define Styles: Custom circle button

About TextView: What do you want to do? Change font? Change colour? Change Size?

You've XML attributes for TextViews if you're doing this by XML. Except to change font, that it was implemented in 4.1.

android:text="TextView"
android:textColor="#288BA2"
android:textSize="30sp"
Community
  • 1
  • 1
Reinherd
  • 5,476
  • 7
  • 51
  • 88