Mult proto + new app
This commit is contained in:
@@ -10,6 +10,7 @@ import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowInsets;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
@@ -127,6 +128,7 @@ public class LogActivity extends Activity {
|
||||
});
|
||||
|
||||
setContentView(root);
|
||||
applyInsets(root, dp(16), dp(14), dp(16), dp(12));
|
||||
}
|
||||
|
||||
private void appendLogLine(String line) {
|
||||
@@ -177,4 +179,27 @@ public class LogActivity extends Activity {
|
||||
private int dp(int value) {
|
||||
return Math.round(value * getResources().getDisplayMetrics().density);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pads the root by the system bar insets. Required from API 35, where the
|
||||
* activity is laid out edge to edge and would otherwise draw under the
|
||||
* status and navigation bars.
|
||||
*/
|
||||
private void applyInsets(final View root, final int l, final int t, final int r, final int b) {
|
||||
root.setOnApplyWindowInsetsListener((v, insets) -> {
|
||||
int top, bottom, left, right;
|
||||
if (Build.VERSION.SDK_INT >= 30) {
|
||||
android.graphics.Insets bars = insets.getInsets(WindowInsets.Type.systemBars());
|
||||
top = bars.top; bottom = bars.bottom; left = bars.left; right = bars.right;
|
||||
} else {
|
||||
top = insets.getSystemWindowInsetTop();
|
||||
bottom = insets.getSystemWindowInsetBottom();
|
||||
left = insets.getSystemWindowInsetLeft();
|
||||
right = insets.getSystemWindowInsetRight();
|
||||
}
|
||||
v.setPadding(l + left, t + top, r + right, b + bottom);
|
||||
return insets;
|
||||
});
|
||||
root.requestApplyInsets();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user