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
in java/MainActivity show progressbar:
then hide when ready:
It does the job except background image is just stretched to fit and doesn't always look great as it loses its aspect ratio.
in activity_main.xml I have
Code:
<ProgressBar
android:id="@+id/progressBar1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="@mipmap/splash"
android:indeterminate="false"
android:padding="120dp"
android:textAlignment="center" />
in java/MainActivity show progressbar:
Code:
if (isNetworkStatusAvialable(getApplicationContext())) {
mWebView.setWebViewClient(new com.myapp.webview.MyAppWebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
findViewById(R.id.progressBar1).setVisibility(View.VISIBLE);
}
then hide when ready:
Code:
@Override
public void onPageFinished(WebView view, String url) {
//hide loading image
findViewById(R.id.progressBar1).setVisibility(View.GONE);
//show url in webview
findViewById(R.id.web_view).setVisibility(View.VISIBLE);
//Close loading
mySwipeRefreshLayout.setRefreshing(false);
}
});
It does the job except background image is just stretched to fit and doesn't always look great as it loses its aspect ratio.