Hoang
Hoang

Reputation: 1047

How to make drawable by layer-list

I want to custom the edit text as below image
enter image description here

Currently, I am using a View with width = 1dp to trick for this case.
Actually it's a dirty approach so I want to make a drawable file by layer-list then add to background of EditText. It will look like:

______________ 

______________ 

On other hand, as Android Edit Text attribute we can use drawableTop and drawableBottom to add a divider ( just a shape line ) into.

My problem :
Method 1 -> I can not create a background with top and bottom as a line
Method 2 -> I have tried to use drawableTop but it does not show

Upvotes: 0

Views: 230

Answers (1)

maggie wan
maggie wan

Reputation: 74

try this

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
      <item>
        <shape android:shape="rectangle">
         <solid android:color="#a8a8a8" />
        </shape>
      </item>
      <item android:top="2dp" android:bottom="2dp">
        <shape android:shape="rectangle">
         <solid android:color="#ffffff" />
        </shape>
      </item>
    </layer-list>

Upvotes: 1

Related Questions