【问题标题】:Android.Views.InflateException: Binary XML file line #1: Error inflating class android.widget.ButtonAndroid.Views.InflateException: Binary XML file line #1: Error inflating class android.widget.Button
【发布时间】:2020-01-05 05:38:52
【问题描述】:

我需要你的帮助。当我尝试在手机上编译应用程序时出现此错误:

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

嗯,它说 Button 所以,这是我在我的 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" />

我的drawable文件夹中有一个xml文件调用: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>

谢谢。

【问题讨论】:

  • 您是否进行了一些调试以试图缩小问题范围?
  • 你能把android:background="@drawable/BotonLoginStyle"删掉,看看是否还有错误吗?
  • 当我删除 android:background="@drawable/BotonLoginStyle" 它工作:/

标签: android visual-studio xamarin


【解决方案1】:

我只做了四个步骤,问题就解决了。

  1. 清洁溶液 和 AppData/xamarin/zips
  2. 从移动设备中删除已安装的 apk。
  3. 从移动设备中删除 Mono 共享运行时
  4. 重建解决方案

【讨论】:

  • 这对我有用。但是,只有在模拟器上才有可能。如何在应用程序安装期间从设备中删除 Mono Shared Runtime?我的 apk 已上传到 Play 商店。有没有办法让它删除用户的单声道运行时?
【解决方案2】:

好吧,我已经删除了&lt;layout-list&gt;,我把它放在了&lt;layer-list&gt;上,它有效。谢谢你的时间! :)

【讨论】:

    【解决方案3】:

    删除

    android:background="@drawable/BotonLoginStyle"

    然后再试一次这个drawable或使用其他drawable。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多