Pavan Tiwari
Pavan Tiwari

Reputation: 3187

Show bg image with progress-bar on splash screen

I am trying to show a BG Image and Progress-bar on splash screen.

Code for splash.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:layout_height="match_parent" android:layout_width="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android" android:background="@drawable/spalsh">
        <ProgressBar
            android:id="@+id/loading"
            style="?android:progressBarStyleLarge"
            android:layout_width="wrap_content"
            android:indeterminateDrawable="@layout/progressbartemplate"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|center"
            android:layout_marginBottom="10dp" />
</FrameLayout>

Then on Style I have

<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:background" >@layout/splash</item>
    </style>

Then I applied this style to Activity in manifiestfile

<activity
            android:name="com.test.SplashActivity" android:theme="@style/SplashTheme"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

But when the app starts I can not see the image and progress-bar while same i can see on the design view. Same code will work if i use Layer-List and remove the progressbar.

Can someone pls suggest me how can i show the bg image with progress-bar at bottom?

Thanks in advance

Upvotes: 0

Views: 404

Answers (2)

Nour Eldien Mohamed
Nour Eldien Mohamed

Reputation: 961

I think there is problem in size of splash image you have to resize it by follow blow steps

1- right click on res

2- right click on drawable

3- click on new

4- Batch Drawable importer

5- click on plus + chose splash

I hope it will help you

Upvotes: 1

Sandip Singh
Sandip Singh

Reputation: 386

try this, I hope this may resolve your issue.

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@mipmap/ic_launcher"
    tools:context="com.example.viral.myapplication.MainActivity">

    <ProgressBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        android:padding="12dp"/>

</RelativeLayout>

Upvotes: 0

Related Questions