我正在尝试在 Visual Studio 的 Monodroid 应用程序中实现 .java 启动画面,无论如何我希望启动画面从资源布局中获取它的内容 View 。我试图像这样得到它:
setContentView(R.layout.AppSplash);
也试过:
setContentView(Resource.layout.AppSplash);
还有:
setContentView("@layout/AppSplash");
我收到这样的错误消息:
package R does not exist
R 因资源而改变或:
cannot find symbol
symbol : method setContentView(java.lang.String)
location: class SwimmerTimesCalc.SplashActivity
setContentView("@layout/AppSplash");
当我尝试@layout/AppSplash 选项时
如何访问 Monodroid 资源来设置启动画面的布局?
最佳答案
This应该可以帮助您入门。
如果您想使用专门用于创建您自己的初始屏幕的布局,然后使用该资源在您的 Activity 中显示它,那么您可以使用类似这样的东西。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/SplashScreenLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/SplashDefault"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:scaleType="centerCrop" />
</RelativeLayout>
然后在您的 Activity 中,您只需设置内容 View 即可。
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.SplashLayout);
}
关于android - 如何从 .java 文件启动画面访问 Monodroid 资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12005296/