我正在Visual Studio上使用Xamarin开发Android应用程序。
但是我在手机上部署应用程序时遇到了这个错误:
未处理的异常:Android.Views.InflateException:二进制XML文件行#1:
在更改serviceScreen中的UI之前,应用程序运行正常。
XML文件
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f0ffa0"
android:scrollIndicators="right"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="73.7dp"
android:id="@+id/linearLayout1"
android:background="#ecf1b7">
<TextView
android:text="ICICI SERVICES"
android:layout_width="214.3dp"
android:layout_height="43.3dp"
android:id="@+id/serviceText"
android:alpha="1"
android:textColor="#000000"
android:textSize="27dp"
android:textStyle="bold"
android:typeface="serif"
android:layout_marginTop="17dp"
android:layout_marginLeft="60dp" />
<ImageView
android:src="@drawable/services"
android:layout_width="64.0dp"
android:layout_height="53.0dp"
android:id="@+id/servicesLogo"
android:layout_marginTop="10dp"
android:layout_marginLeft="7dp" />
</LinearLayout>
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="3.0dp"
android:layout_marginBottom="0dp"
android:background="#414347"
android:clickable="false"
android:text="Button" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout2"
android:layout_marginTop="50dp">
<ImageButton
android:src="@drawable/personaldetails2"
android:layout_width="97.0dp"
android:layout_height="89.0dp"
android:id="@+id/servicePersonal"
android:scaleType="centerInside"
android:background="#ffffff"
android:layout_marginLeft="50dp"
android:layout_marginTop="0dp"
android:clickable="true"
android:hapticFeedbackEnabled="true" />
<ImageButton
android:src="@drawable/carddetails"
android:layout_width="98.7dp"
android:layout_height="87.0dp"
android:id="@+id/serviceCard"
android:scaleType="centerInside"
android:background="#ffffff"
android:layout_marginLeft="65dp"
android:clickable="true"
android:hapticFeedbackEnabled="true" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout2"
android:layout_marginTop="20dp">
<ImageButton
android:src="@drawable/fundtransfer"
android:layout_width="95.0dp"
android:layout_height="87.0dp"
android:id="@+id/serviceFund"
android:background="#ffffff"
android:scaleType="centerInside"
android:layout_marginLeft="50dp"
android:clickable="true"
android:hapticFeedbackEnabled="true" />
<ImageButton
android:src="@drawable/billpayment"
android:layout_width="97.7dp"
android:layout_height="95.7dp"
android:id="@+id/serviceBill"
android:scaleType="centerCrop"
android:background="#ffffff"
android:layout_marginLeft="65dp"
android:clickable="true"
android:hapticFeedbackEnabled="true" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout2"
android:layout_marginTop="20dp">
<ImageButton
android:src="@drawable/accountdetails"
android:layout_width="95.0dp"
android:layout_height="87.0dp"
android:id="@+id/serviceAccount"
android:scaleType="centerInside"
android:background="#ffffff"
android:layout_marginLeft="52dp"
android:clickable="true"
android:hapticFeedbackEnabled="true" />
<ImageButton
android:src="@drawable/transactionhistory"
android:layout_width="85.3dp"
android:layout_height="match_parent"
android:id="@+id/serviceTransaction"
android:scaleType="centerInside"
android:background="#ffffff"
android:layout_marginLeft="70.0dp"
android:clickable="true"
android:hapticFeedbackEnabled="true" />
</LinearLayout>
<ImageButton
android:src="@android:drawable/ic_menu_gallery"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/serviceBranch"
android:visibility="gone" />
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="3.0dp"
android:layout_marginBottom="0dp"
android:background="#414347"
android:clickable="false"
android:text="Button"
android:layout_marginTop="100dp" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="74.0dp"
android:id="@+id/linearLayout3"
android:background="#ecf1b7">
<TextView
android:text="*Back Functionality has been Disabled"
android:layout_width="wrap_content"
android:layout_height="23.7dp"
android:id="@+id/textView1"
android:textColor="#000000"
android:textStyle="italic"
android:textSize="14dp"
android:typeface="sans"
android:layout_marginLeft="10.0dp" />
<Button
android:id="@+id/button1"
android:background="#414347"
android:clickable="false"
android:layout_width="3dp"
android:layout_height="75dp"
android:layout_marginLeft="39dp" />
<ImageButton
android:src="@drawable/easeofaccess"
android:layout_width="64.7dp"
android:layout_height="53.3dp"
android:id="@+id/imageButton1"
android:background="#ecf1b7"
android:scaleType="centerInside"
android:layout_marginTop="10dp"
android:layout_marginLeft="5dp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
C#文件
using System;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Widget;
namespace Hackathon_ICICI
{
[Activity(Label = "Services")]
public class Services : Activity
{
MainSpeaker speaker = new MainSpeaker();
//string text = Intent.GetStringExtra("MyData") ?? "Data not available";
public override void OnBackPressed()
{
//base.OnBackPressed();
speaker.Main_speaker("This functionality has been disabled.");
}
protected override void OnRestart()
{
base.OnRestart();
speaker.Main_speaker("Please select the service you would like to know about.");
speaker.Main_speaker("View Personal Details.");
speaker.Main_speaker("Card Details.");
speaker.Main_speaker("Account Details.");
speaker.Main_speaker("Transaction Details");
//speaker.Main_speaker("Branch Details.");
}
protected override void OnPause()
{
base.OnPause();
//speaker.Main_speaker("I've been PAUSED!");
// Code can be added here to stop the MainSpeaker Class!
}
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.servicesScreen);
speaker.Main_speaker("Welcome to ICICI Special Services. Please select the service you would like to know about.");
speaker.Main_speaker("View Personal Details.");
speaker.Main_speaker("Card Details.");
speaker.Main_speaker("Account Details.");
speaker.Main_speaker("Transaction Details");
//speaker.Main_speaker("Branch Details.");
// Create your application here
}
}
}
答案 0 :(得分:0)
缩小图像大小解决了问题。