0

I have to create this view in android:

enter image description here

But this is not a button. How can I create this view?

Tolgay Toklar
  • 4,151
  • 8
  • 43
  • 73
  • You can use a `View` with custom background. Similar question: http://stackoverflow.com/questions/16161448/how-to-make-layout-with-rounded-corners – Rami Sep 22 '15 at 10:34
  • I have added my answer, with same coloring scheme you have shown in image – Akber Sep 22 '15 at 10:53

3 Answers3

3

I assume this is a LinearLayout with 2 TextViews in it. You can create a custom background drawable in xml like this:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<stroke android:color="YOUR ORANGE HEX COLOR" android:width="4dp"/>
<corners
    android:bottomRightRadius="25dp"
    android:bottomLeftRadius="25dp"
    android:topLeftRadius="25dp"
    android:topRightRadius="25dp"/>
</shape>

Adjust the storke width and the radius values as per your need.

Eric B.
  • 4,622
  • 2
  • 18
  • 33
1
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >

<solid android:color="#ffffff"/>
<corners android:radius="12dp" />// set your radius accordingly

<stroke
    android:width="3dp"
    android:color="#f48529" >
</stroke>

</shape>

Make any desired layout and set this file(put it in the drawable folder) as background, here radius will be applied equally on each corner.

Akber
  • 521
  • 4
  • 10
0

Put this xml in drawable folder

Round.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
 <item android:state_pressed="true" >
     <shape android:shape="rectangle"  >
         <corners android:radius="3dip" />
         <stroke android:width="1dip" android:color="#ffffff" />
         <gradient android:angle="-90" android:startColor="#ffffff" android:endColor="#ffffff"  />            
     </shape>
 </item>
<item android:state_focused="true">
     <shape android:shape="rectangle"  >
         <corners android:radius="3dip" />
         <stroke android:width="1dip" android:color="#ffffff" />
         <solid android:color="#ffffff"/>       
     </shape>
 </item>  
<item >
    <shape android:shape="rectangle"  >
         <corners android:radius="3dip" />
         <stroke android:width="1dip" android:color="#ffffff" />
         <gradient android:angle="-90" android:startColor="#ffffff" android:endColor="#ffffff" />            
     </shape>
 </item>
</selector>

And use it as background of anyview like view , button , imagebutton etc.

KishuDroid
  • 5,411
  • 4
  • 30
  • 47