Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Entry: Modifying the thickness of bottom line and aligning placeholder with text

ghasanghasan Member ✭✭

Hi,

I have been experimenting with unifying the thickness of Entry's bottom line to have the same thickness while focused and unfocused.

I have been looking at this question: https://stackoverflow.com/questions/34588520/edittext-background-as-straight-line

And I have tried what the OP tried, and I got exactly what they got. A line in the middle of the entry.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="line">

    <stroke 
        android:color="#FA58AC"
        android:width="1dp"/>

</shape>

And at the custom renderer inheriting from MaterialEntryRenderer, I added this code to set the drawable as the background.

EditText.SetBackground(Resources.GetDrawable(Resource.Drawable.EditTextBottomLine));

Then I tried the accepted solution, but it does not work at all. It makes a grey background to the whole entry, I could not get it to work.

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

<item
    android:left="-2dp"
    android:right="-2dp"
    android:top="-2dp">
    <shape>
        <solid android:color="@android:color/white" />

        <stroke
            android:width="1dp"

            android:color="@android:color/holo_green_light" />
    </shape>
</item>

Does anyone how to get this working?

Also, I want to make the placeholder sit at the same position the text sits on, is this possible? The placeholder is positioned a bit above the text position (when unfocused).

I could not find a proper object that seem to control the placeholder in EditText or Control properties of MaterialEntryRenderer of Android.

Thanks for your help.

Sign In or Register to comment.