1. Are you ready for the Galaxy S20? Here is everything we know so far!

Full screen background behind ProgressBar & maintain aspect ratio

Discussion in 'Android Development' started by mcfc4heatons, Apr 2, 2021.

  1. mcfc4heatons

    mcfc4heatons Lurker
    Thread Starter

    Newbie question, I'm trying to work out how to have a full screen background behind ProgressBar, and need background image to keep its aspect ratio. As I understand it it might not be possible to maintain aspect ratio with background image?

    in activity_main.xml I have

    Code (Text):
    1.         <ProgressBar
    2.             android:id="@+id/progressBar1"
    3.             android:layout_width="match_parent"
    4.             android:layout_height="match_parent"
    5.             android:layout_gravity="center"
    6.             android:background="@mipmap/splash"
    7.             android:indeterminate="false"
    8.             android:padding="120dp"
    9.             android:textAlignment="center" />
    in java/MainActivity show progressbar:

    Code (Text):
    1. if (isNetworkStatusAvialable(getApplicationContext())) {
    2.     mWebView.setWebViewClient(new com.myapp.webview.MyAppWebViewClient() {
    3.  
    4.         @Override
    5.         public void onPageStarted(WebView view, String url, Bitmap favicon) {
    6.             findViewById(R.id.progressBar1).setVisibility(View.VISIBLE);
    7.         }
    then hide when ready:

    Code (Text):
    1.                 @Override
    2.                 public void onPageFinished(WebView view, String url) {
    3.                     //hide loading image
    4.                     findViewById(R.id.progressBar1).setVisibility(View.GONE);
    5.                     //show url in webview
    6.                     findViewById(R.id.web_view).setVisibility(View.VISIBLE);
    7. //Close loading
    8.                     mySwipeRefreshLayout.setRefreshing(false);
    9.                 }
    10.             });
    It does the job except background image is just stretched to fit and doesn't always look great as it loses its aspect ratio.
     



    1. Download the Forums for Android™ app!


      Download

       
Loading...
Similar Threads - Full screen background
  1. behrprofl
    Replies:
    1
    Views:
    405
  2. steelpegasus
    Replies:
    7
    Views:
    547
  3. Pochoco
    Replies:
    6
    Views:
    742
  4. coldpumpkin
    Replies:
    2
    Views:
    496
  5. and200cc
    Replies:
    9
    Views:
    3,045
  6. dkperez
    Replies:
    2
    Views:
    436
  7. spman
    Replies:
    1
    Views:
    780
  8. behrprofl
    Replies:
    6
    Views:
    1,571
  9. Axelmorgana
    Replies:
    0
    Views:
    620
  10. ThomasGrace
    Replies:
    1
    Views:
    588

Share This Page

Loading...