Search code examples
androidandroid-activityandroid-stylesappcompatactivity

After fixing error "Root element paints background" why image is repeated in other view?


After fixing "Possible overdraw: Root element paints background" error new issue is arise in my splash activity; the image set in background is repeated in progressbar background

here is my manifiest.xml code

<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 code

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

and java code

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>

and screenshot enter image description here


Solution

  • It is simple, you are setting background in your activity style, this means you are setting that background for all view within it. Just remove that line

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

    If you are creating splash screen - use windowBackground instead