DavDeveloper
DavDeveloper

Reputation: 271

Android - EditText border is not visible

Hi have a issue with the border from EditText

Here is my background/border xml code:

    <?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <corners android:radius="20dp"/>
    <padding android:left="10dp" android:right="10dp" android:top="10dp" android:bottom="10dp"/>
    <solid  android:color="#efefef"/>
    <stroke android:width="2dp" android:color="#efefef"/>
</shape>

But the border is not showing.

Edit:

Here my EditText Code

<EditText
    android:id="@+id/stackoverflow"
    android:layout_width="201dp"
    android:layout_height="53dp"
    android:layout_marginTop="8dp"
    android:layout_marginEnd="20dp"
    android:background="@drawable/backwithborder"
    android:backgroundTint="@color/colorPrimary"
    android:ems="10"
    android:importantForAutofill="no"
    android:inputType="stackoverflow"
    android:textAlignment="viewStart"
    android:textSize="24sp"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toEndOf="@+id/stackoverflow"
    app:layout_constraintTop_toTopOf="@+id/stackoverflow"
    tools:targetApi="o" />

Upvotes: 0

Views: 1772

Answers (3)

Momen Zaqout
Momen Zaqout

Reputation: 1498

the code works, but the problem is you use the same color for border and solid. so the border will be as a part of solid. try to change the color of the border like this.

<stroke android:width="2dp" android:color="#3a3a3a"/>

Based on your update, you have some errors in your EditText

<EditText
    android:id="@+id/stackoverflow"
    android:layout_width="201dp"
    android:layout_height="53dp"
    android:layout_marginTop="8dp"
    android:layout_marginEnd="20dp"
    android:background="@drawable/backwithborder"
    android:backgroundTint="@color/colorPrimary"
    android:ems="10"
    android:importantForAutofill="no"
    android:inputType="stackoverflow"
    android:textAlignment="viewStart"
    android:textSize="24sp"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toEndOf="@+id/stackoverflow"
    app:layout_constraintTop_toTopOf="@+id/stackoverflow"
    tools:targetApi="o" />

1- there is no stackoverflow inputType

2- when using android:backgroundTint, the view will take its color, so background will be useless.

try to remove android:backgroundTint="@color/colorPrimary" and android:inputType="stackoverflow".

don't forget to change stroke color

Upvotes: 3

K M Rejowan Ahmmed
K M Rejowan Ahmmed

Reputation: 1267

Remove this line from the code bud-

android:backgroundTint="@color/colorPrimary"

And also use different color for stroke and solid in the drawable.

Upvotes: 1

Manasa
Manasa

Reputation: 1

Change the color of stroke and try increasing the stroke width

Upvotes: 0

Related Questions