0

Hi i am trying to make rectangular Edit-text style like below image for this i used below code but its not showing Edit-text like my below image can some one help me please

rect_text_edit:-

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:padding="10dp"
    android:shape="rectangle">
    <solid android:color="#FFFFFF" />
    <corners
        android:bottomLeftRadius="5dp"
        android:bottomRightRadius="5dp"
        android:topLeftRadius="5dp"
        android:topRightRadius="5dp"/>
</shape>

login.xml:

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="@dimen/layout_padding"
        android:orientation="vertical">

        <EditText
            android:id="@+id/searchBox"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/rect_text_edit"
            android:textColor="@color/black"
            android:textCursorDrawable="@null"
            android:singleLine="true"
            android:padding="10dp">

        </EditText>

    </LinearLayout>

</RelativeLayout>

enter image description here

AbhiRam
  • 2,033
  • 7
  • 41
  • 94
  • You need to use `stroke` for border . – ADM Apr 20 '18 at 05:22
  • For this kind of background, you must use nine-patch image – Raj Suvariya Apr 20 '18 at 05:24
  • @Adm please post some code – AbhiRam Apr 20 '18 at 05:27
  • @AbhiRam refer https://www.android-examples.com/set-border-to-edittext-in-android-programmatically/ – MinnuKaAnae Apr 20 '18 at 05:29
  • First of all your title is misleading (There is no rect shape). And the image you have added is pre-lollipop style of `EditText`. It will show flat stroke in lollipop+ . So Edit your question if you want to keep it that way in all android versions ? Also look into [same question](https://stackoverflow.com/questions/21480398/edittext-underline-below-text-property). – ADM Apr 20 '18 at 05:38
  • @Adm i chnage my question title – AbhiRam Apr 20 '18 at 06:10

0 Answers0