Issue
This is the edittext I want to have:
This is what I got so far:
Two issues:
as you can see, the top border should be much smaller.
I set padding on the code, but it didn't work an as you can see. The text is at top of the edittext. How can I make it align center and in the middle of edittext?
This is my drawable xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="15dp"
android:shape="rectangle" >
<solid android:color="#3C1251" />
<corners
android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp" />
<stroke
android:width="2.3dp"
android:color="#56DEF1" />
</shape>
Solution
To reduce the size of the top border, you might try using an inset
to shift the entire drawable up by a pixel or two.
For example, for a 1dp top border you might set the stroke width to 3, and the insetTop to -2.
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetTop="-2dp">
<shape
android:padding="15dp"
android:shape="rectangle" >
<solid android:color="#3C1251" />
<corners
android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp" />
<stroke
android:width="3dp"
android:color="#56DEF1" />
</shape>
</inset>
To align the text to the center, try setting android:gravity
on the EditText to center
.
To put "padding" around the edge of the border, try setting a layout_margin
.
<EditText
...
android:background="@drawable/ourDrawable"
android:text="text goes here"
android:gravity="center"
android:layout_margin="5dp" />
Answered By - trooper
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.