android - 修复错误“根元素绘制背景”后,为什么图像在其他视图中重复?
问题描述
修复“可能的透支:根元素绘制背景”错误后,我的启动活动中出现了新问题;背景中设置的图像在进度条背景中重复
这是我的manifiest.xml代码
<activity
android:name="com.dictionary.SplashActivity"
android:launchMode="singleTask"
android:screenOrientation="unspecified"
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
splash.xml 代码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="18dp"
android:theme="@style/BrownColor" />
</RelativeLayout>
和java代码
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.three_splash);}
样式.xml
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="AppTheme.NoActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:background">@drawable/splash</item>
</style>
<style name="BrownColor" parent="ThemeOverlay.AppCompat.Light">
<item name="colorAccent">#8e2308</item>
</style>
解决方案
很简单,您正在为活动样式设置背景,这意味着您正在为其中的所有视图设置该背景。只需删除该行
<item name="android:background">@drawable/splash</item>
如果您正在创建启动画面 - 请改用 windowBackground
推荐阅读
- asp.net-core - 如何在 ASP.NET Core 中间件中直接将响应主体设置为文件流?
- php - 需要帮助将日期数据从 csv(m/d/Y) 转换为 Y/m/d(将其写入另一个 csv)
- selenium-webdriver - Selenium Web 驱动程序的文件上传功能,用于不带 AutoIt 或 Skuliii 的非输入按钮
- java - 为什么以下代码没有产生正确的输出?
- sql - 不能从其他 hive 格式中选择插入 hive ORC 格式表
- scala - 使用 Spark Dataframes/Datasets 的动态 GroupBy 和计数
- laravel - vuejs上的动态选择框数据绑定
- python - 为什么不能用硒获得 hkdrates 表?
- javascript - 过滤数组中的两个对象并追加到组件中
- swift - 我可以在两个不同的 collectionView 之间有一个自定义视图吗?