meluluji
meluluji

Reputation: 319

Android.Views.InflateException: Binary XML file line #1: Error inflating class android.widget.Button

I need your help. I get this error when I try to compile my application on my phone:

Android.Views.InflateException: Binary XML file line #1: Error inflating class android.widget.Button

Well, it says Button so, this is my code in my axml:

<Button
    android:text="Iniciar sesión"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="15"
    android:id="@+id/IniciarButton"
    android:background="@drawable/BotonLoginStyle"
    android:layout_marginLeft="50dp"
    android:layout_marginRight="50dp"
    android:textSize="15sp" />

and I have a xml file in my drawable folder call: BotonLoginStyle

<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_pressed="false">
    <layout-list>
      <item android:right="5dp" android:top="5dp">
        <shape>
          <corners android:radius="2dp"></corners>
          <solid android:color="#B40404"></solid>
        </shape>
      </item>
      <item android:right="2dp" android:top="2dp">
        <shape>
          <gradient android:angle="270" android:endColor="#F5A9A9" android:startColor="#F5A9A9"></gradient>
          <corners android:radius="2dp"></corners>
          <stroke android:width="1dp" android:color="#F5A9A9"></stroke>
          <padding android:left="10dp" android:right="10dp" android:top="10dp"></padding>
        </shape>
      </item>
    </layout-list>
  </item>
  <item android:state_pressed="true">
    <layout-list>
      <item android:right="5dp" android:top="5dp">
        <shape>
          <corners android:radius="2dp"></corners>
          <solid android:color="#B40404"></solid>
        </shape>
      </item>
      <item android:right="2dp" android:top="2dp">
        <shape>
          <gradient android:angle="270" android:endColor="#DF0101" android:startColor="#F5A9A9"></gradient>
          <corners android:radius="2dp"></corners>
          <stroke android:width="1dp" android:color="#F5A9A9"></stroke>
          <padding android:left="10dp" android:right="10dp" android:top="10dp"></padding>
        </shape>
      </item>
    </layout-list>
  </item>
</selector>

Thank you.

Upvotes: 1

Views: 2247

Answers (3)

Hassan Hosseini
Hassan Hosseini

Reputation: 420

Remove

android:background="@drawable/BotonLoginStyle"

and try again this drawable or use other drawables.

Upvotes: 0

iamguni
iamguni

Reputation: 29

I just followed four steps and the problem solved.

  1. Clean Solution and AppData/xamarin/zips
  2. Remove installed apk from mobile devices.
  3. Remove Mono Shared Runtime from mobile devices
  4. Rebuild solution

Upvotes: 1

meluluji
meluluji

Reputation: 319

Well, I've removed <layout-list> and I put this <layer-list>and it works. Thanks for your time! :)

Upvotes: 0

Related Questions