Xamarin Main.axml更改不会显示在应用程序中

时间:2016-09-21 09:36:10

标签: xamarin visual-studio-2015 xamarin.android

enter image description here enter image description here

我在这里对背景做了一个基本的改动,我将颜色改为白色。 但是当我在xamarin附带的模拟器中构建并运行应用程序时,根本没有任何变化,我也尝试过像按钮这样的东西。我尝试的一些解决方案是重建,重新生成resource.designer,重新设计项目但没有任何效果。为什么这不起作用?

编辑:每个请求,添加了MainActivity.cs的代码

using Android.App;
using Android.Widget;
using Android.OS;

namespace Tresette
{
    [Activity(Label = "Tresette", MainLauncher = true, Icon = "@drawable/icon")]
    public class MainActivity : Activity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            // SetContentView (Resource.Layout.Main);
        }
    }
}

和Main.axml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:minWidth="25px"
    android:minHeight="25px"
    android:background="@android:color/background_light" />

如您所见,它们是默认生成的文件,并在.axml文件中添加了背景。

1 个答案:

答案 0 :(得分:4)

您永远不会使用Main.axml文件。在MainActivity.cs中,设置布局的行被注释掉:

// SetContentView (Resource.Layout.Main);

在Android上,Activity必须选择其布局,或者从具有内置布局的ListActivity派生。

相关问题