Skip to content

Commit d129a36

Browse files
MainActivity: fix top padding, making it depend on device's properties rather than being hardcoded
1 parent 84c35dc commit d129a36

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

app/src/main/java/space/myhomework/android/MainActivity.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@ protected void onCreate(Bundle savedInstanceState) {
6868

6969
setTitle("MyHomeworkSpace");
7070

71+
// TODO: for some reason, I cannot find a good way of handling this
72+
// ("this" meaning showing the top navbar under the system status bar, and showing the bottom tabbar under the system nav bar)
73+
// it works for the bottom but not the top
74+
// so, manually hack the top into working
75+
// I think maybe related: https://stackoverflow.com/a/73938386/2178519
76+
int statusBarHeight = 0;
77+
int statusBarHeightID = getResources().getIdentifier("status_bar_height", "dimen", "android");
78+
if (statusBarHeightID != -1) {
79+
statusBarHeight = getResources().getDimensionPixelSize(statusBarHeightID);
80+
}
81+
findViewById(R.id.main_frame_layout).setPadding(0, statusBarHeight, 0, 0);
82+
7183
final Context ctx = this;
7284
final ProgressDialog progressDialog = ProgressDialog.show(this, "", "Loading, please wait...", true);
7385
progressDialog.show();

app/src/main/res/layout/activity_main.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
android:layout_width="match_parent"
1313
android:layout_height="match_parent"
1414
android:id="@+id/main_frame_layout"
15-
android:paddingTop="36dp"
1615
tools:context="space.myhomework.android.MainActivity">
1716

1817
<androidx.coordinatorlayout.widget.CoordinatorLayout

0 commit comments

Comments
 (0)