Tuesday, 29 October 2013

Android-To draw a line and rounded corner view(like rounded-corner Editext and Button).

1)First,To Draw a line in XML by using simple View,Just add this following.

        <View
          android:layout_width="match_parent"
          android:layout_height="1dp"
          android:background="@android:color/black" />

2)Next,For rounded corner view just create an XML in /drawable folder and add this following code.

   round_corner.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

    <corners
        android:bottomLeftRadius="3dp"
        android:bottomRightRadius="3dp"
        android:radius="3dp"
        android:topLeftRadius="3dp"
        android:topRightRadius="3dp" />
   <solid
       android:color="@android:color/white"/>
   </shape>

3)At last you add this xml in a background to your view like following:-

<EditText
          android:id="@+id/ed1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:background="@drawable/round_corner"
        />

Done..Thanks.

0 comments:

Post a Comment

 

Copyright © Unique Android Tutorial.. Design by Free CSS Templates | Blogger Theme by BTDesigner | Powered by Blogger