Christian
Christian

Reputation: 26387

Removing the margin/padding from the Entry in Xamarin Android via styles.xml

According to another StackOverflow question it's possible to remove the margin of a normal Button via styles.xml.

I would like to do the same for the margin/padding of Entry. Given that my trivial assumption would be that it uses an EditText beneath I tried:

  <style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="editTextStyle">@style/MyEditText</item>
  </style>

  <style name="MyEditText" parent="Widget.AppCompat.EditText">
    <item name="android:layout_margin">0dip</item>
  </style>

Unfortunately, this doesn't have any effect. Even when I use 50dip as a value there's no effect. What are the correct setting in styles.xml to affect the Entry-widgit?

Upvotes: 1

Views: 965

Answers (1)

SushiHangover
SushiHangover

Reputation: 74114

In your MainTheme.Base

<item name="android:editTextStyle">@style/EditTextStyle</item>

And your @style/EditTextStyle

<style name="EditTextStyle" parent="@android:style/Widget.EditText">
    <item name="android:layout_margin">0dip</item>
    <item name="android:padding">0dip</item>
</style>

Note: This going to depend upon your layout, as the "margins" are to parent Android layout containers (ViewGroup) and thus your Forms' Entry might not be effected. If you are not sure that you have set this up correctly, throw a color into the style to double check, something like all Entries having Green text:

<item name="android:textColor">#00f000</item>

Upvotes: 1

Related Questions