android - 为什么在切换到新主题后仍然使用 android:background 的值
问题描述
我在 Xamarin.Android 应用程序的 Style.xml 中有这个:
<resources>
<!-- Splash styles -->
<style name="Theme.Splash" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:background">@drawable/splash_drawable</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsTranslucent">false</item>
<item name="android:windowIsFloating">false</item>
<item name="android:backgroundDimEnabled">true</item>
</style>
<!-- Theme -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- window:background is not set here, but even if it set (to say, @null for eg), there is no change. The value from Theme.Splash is preserved. -->
....
我的 MainActivity.cs 看起来像这样:
[Activity(
Label = "My app",
Icon = "@drawable/icon",
Theme = "@style/Theme.Splash",
MainLauncher = true,
LaunchMode = LaunchMode.SingleTask,
ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize | ConfigChanges.Locale | ConfigChanges.LayoutDirection,
ScreenOrientation = ScreenOrientation.Portrait
)
]
public class MainActivity : FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
// Changing to App theme since we are in OnCreate and we are ready to
// "hide" the splash.
// But the android:background property value from Theme.Splash remains.
base.Window.RequestFeature(WindowFeatures.ActionBar);
base.SetTheme(Resource.Style.AppTheme);
...
如何删除设置的内容android:background
?它会导致重大问题,因为当应用程序完成加载时它会重叠我的所有视图。
注意:我不能使用android:windowBackground
inTheme.Splash
代替,因为这会导致我的自定义启动页面移动到状态栏下方。
解决方案
只需android:background
在 AppTheme 中覆盖。
推荐阅读
- javascript - 如何在 X 秒内执行命令?
- grails - 首次使用 Grails 包装器时必须连接到 Internet
- r - 在R中的行中添加多列计数频率
- vb.net - 如果选中任何复选框,则将启用某些文本框
- asp.net - 如何使用 SDK 在单独的 ASP.NET 端点中订阅 Microsoft Graph 更改通知
- url - 如何通过 URL 链接在 Django 中导航 State-District-taluk-village
- python - modulenotfounderror:python 烧瓶上没有名为“sklearn.linear_model.logistic”的模块
- hyperlink - 在 netlogo 中查找未与其他人连接的海龟
- docker - 连接到远程服务器时超时
- windows - .bat 检查窗口或进程是否打开或正在运行,如果没有做其他事情,则执行此操作