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

问题描述 投票:1回答:1

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

这是我的manifest.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.hml tsode

<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

android android-activity android-styles appcompatactivity
1个回答
1
投票

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

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

如果您正在创建启动画面 - 请改用windowBackground

© www.soinside.com 2019 - 2024. All rights reserved.