-1

I have to create a custom component like this:

Custom Component

How to write its custom component?

androider
  • 982
  • 6
  • 16
  • 32
  • You can use just use a `EditText` for you purpose, all you need is to set a varies of attributions. – L. Swifter Aug 29 '16 at 09:52
  • you can use EditText in your layout XML as follows: Add drawable padding as per your layout design guidline. – Rajendra Aug 29 '16 at 09:52

1 Answers1

1

For setting icon on left side of edittext, you can use this:

android:drawableLeft="@mipmap/icon_username"  

where "icon_username" is an image

Set hint like this:

android:hint="username"

To draw border around edittext you should use separate drawable file(xml file)

Sample code for drawable file:

edittext_lines.xml:

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

    <item  android:top="30dp">
        <shape
            android:shape="rectangle">
            <stroke android:width="1dp" android:color="#FFFFFF" />
            <solid android:color="#FFFFFF" />
        </shape>
    </item>

</layer-list>

Final code may look like:

<EditText 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:hint="Username"
       android:background="@drawable/edittext_lines"
       android:drawableLeft="@drawable/round_profile_icon"/> 
Parsania Hardik
  • 4,593
  • 1
  • 33
  • 33