修复错误后,“根元素绘制背景”为什么在其他视图中重复出现图像?

时间:2019-05-01 19:54:57

标签: android android-activity android-styles appcompatactivity

修复“可能的透支:根元素绘制背景”错误后,我的启动活动中出现了新问题;在后台设置的图像在进度条背景中重复

这是我的 manifiedt.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);}

style.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>

和屏幕截图 enter image description here

1 个答案:

答案 0 :(得分:1)

这很简单,您要以活动样式设置背景,这意味着您要为其中的所有视图设置背景。只需删除该行

<item name="android:background">@drawable/splash</item>

如果您要创建初始屏幕,请改用windowBackground

相关问题