Android 在启动屏幕上设置文本和图像:无效的可绘制标记RelativeLayout
我遵循下面链接上的代码 下面是我的代码 splash.xmlAndroid 在启动屏幕上设置文本和图像:无效的可绘制标记RelativeLayout,android,xamarin,xamarin.android,Android,Xamarin,Xamarin.android,我遵循下面链接上的代码 下面是我的代码 splash.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:background="@color/primary" android:layout_width="match_parent" android:lay
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/primary"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerHorizontal="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#fff"
android:text="My test"
android:layout_marginLeft="5dp"
android:textSize="18dp"/>
</LinearLayout>
</RelativeLayout>
操作系统:棒棒糖,Xamarin安卓
更新
飞溅活动
[Activity(Label = "@string/app_name", MainLauncher = true, LaunchMode = Android.Content.PM.LaunchMode.SingleTop, ScreenOrientation = Android.Content.PM.ScreenOrientation.Portrait, Theme = "@style/MySplashTheme")]
public class SplashActivity : AppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
StartActivity(new Intent(this, typeof(ManifestActivity)));
Finish();
}
}
styles.xml
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="MySplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/splash</item>
</style>
</resources>
@可牵引/飞溅
我执行了您的布局,并且工作正常 您是否在colors.xml中声明了原色:
<color name="primary">#3F51B5</color>
#3F51B5
如果要使用android:windowBackground设置活动的with background,则应将其与可绘制资源一起使用,然后将其设置为与活动的主题相同
或者,如果您想使用layout.xml,只需删除主题(因为它不是现在)并设置
//设置此活动的用户界面布局
//布局文件在project res/layout/main_activity.xml文件中定义
setContentView(R.layout.activity\u main)
同样,在这种情况下,您必须在延迟后打算进行下一个活动,而在上一种情况下,windowbackground在加载活动时可见,然后意图被激发,现在布局被加载(现在是backgound),并且很快意图被激发,因此需要一些延迟。我不知道。你能分享你的闪屏活动吗?我想你不需要你的Splash.xml来启动你的闪屏。看看这个示例,了解它应该如何实现:您认为使用splash.xml是问题所在吗?您的splash活动中没有对splash.xml的引用,我假设没有使用splash.xml。您可以尝试测试windowBackground是否正常工作,尝试将@drawable/splash更改为@color/primary,并检查splash活动是否已启动。xml通过@drawable/splash使用。它应该是一个称为AXML的Android布局文件,而不是xml,也许您弄错了?
<color name="primary">#3F51B5</color>