Pasha Shkaran
Pasha Shkaran

Reputation: 1481

Android edit text with custom shape

How can I edit text shape like this.

enter image description here

I mean that right rounded corners and exact same shape. As I understood 9 patch doesn't help me with that.

Upvotes: 0

Views: 314

Answers (3)

Jackson Chengalai
Jackson Chengalai

Reputation: 3937

This ninepatches will help you. just apply this ninepatch images as backgroud of the editText

image1

image2

Upvotes: 1

Mustansar Saeed
Mustansar Saeed

Reputation: 2790

You have to create background image for your EditText. For the other layout, you have to create layout which will look like this. Its not the exact xml but showing you the idea.

<RelativeLayout layout_width="match_parent" layout_height="50dp"> 
       <EditText layout_width="wrap_content" layout_height="wrap_content"
                 android:background="@drawable/editTextBackground" layout_alignParentLeft="true" layout_marginLeft="10dp">

       <ImageView layout_width="wrap_content" layout_height="wrap_content"
                  centerVertical="true" marginLeft="15dp"
                  android:background="@drawable/smily" />

       <ImageView layout_width="wrap_content" layout_height="wrap_content"
                  centerVertical="true" 
                  alignRight="@id/editTExt"
                  android:background="@drawable/camera" />

       <ImageView layout_width="wrap_content" layout_height="wrap_content"
                  centerVertical="true" marginLeft="15dp"
                  alignParentRight="true"
                  android:background="@drawable/mic" />


</RelativeLayout>

Hope this gives you the idea.

Upvotes: 0

Ravi
Ravi

Reputation: 35579

9 patch will be best way in your situation, create 9 patch and set it as background of your EditText.

Here i am giving you sample image, you can try with it.

enter image description here

editText.setBackground(R.drawable.edt_bg);

Upvotes: 2

Related Questions