Add margins to toolbar
This commit is contained in:
parent
1fbfc86199
commit
7b0948383a
@ -13,6 +13,7 @@ import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.WebResourceRequest;
|
||||
@ -25,6 +26,9 @@ import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.loader.app.LoaderManager;
|
||||
import androidx.loader.content.Loader;
|
||||
|
||||
@ -153,6 +157,17 @@ public class PdfViewer extends AppCompatActivity implements LoaderManager.Loader
|
||||
setContentView(binding.getRoot());
|
||||
setSupportActionBar(binding.toolbar);
|
||||
|
||||
// Margins for the toolbar are needed, so that content of the toolbar
|
||||
// is not covered by a system button navigation bar when in landscape.
|
||||
ViewCompat.setOnApplyWindowInsetsListener(binding.toolbar, (v, windowInsets) -> {
|
||||
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
|
||||
mlp.leftMargin = insets.left;
|
||||
mlp.rightMargin = insets.right;
|
||||
v.setLayoutParams(mlp);
|
||||
return windowInsets;
|
||||
});
|
||||
|
||||
binding.webview.setBackgroundColor(Color.TRANSPARENT);
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
|
Loading…
Reference in New Issue
Block a user