Skip to content

Commit

Permalink
Use dynamic status bar height in the left drawer header
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelbussa authored and maniac103 committed May 29, 2023
1 parent 6080d0e commit c8e6809
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 7 additions & 0 deletions app/src/main/java/com/gh4a/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.core.view.GravityCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
Expand Down Expand Up @@ -275,6 +277,11 @@ protected void toggleRightSideDrawer() {
}

protected void configureLeftDrawerHeader(View header) {
ViewCompat.setOnApplyWindowInsetsListener(header, (view, insets) -> {
int statusBarHeight = insets.getInsets(WindowInsetsCompat.Type.systemBars()).top;
view.setPadding(0, statusBarHeight, 0, 0);
return insets;
});
}

protected boolean canSwipeToRefresh() {
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/drawer_header_left.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
android:layout_gravity="center_vertical"
android:orientation="vertical"
android:paddingBottom="8dp"
android:paddingLeft="16dp"
android:paddingTop="24dp">
android:paddingLeft="16dp">

<ImageView
android:id="@+id/avatar"
Expand Down

0 comments on commit c8e6809

Please sign in to comment.