Skip to content

Commit

Permalink
Adjust FAQ layout for edge to edge on Android 15.
Browse files Browse the repository at this point in the history
Issue #1189
  • Loading branch information
mendhak committed Jan 7, 2025
1 parent 93afabe commit b3aea4c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions gpslogger/src/main/java/com/mendhak/gpslogger/Faqtivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import android.view.ViewGroup;
import android.widget.ListView;
import com.commonsware.cwac.anddown.AndDown;
import com.mendhak.gpslogger.common.Strings;
Expand Down Expand Up @@ -54,6 +59,25 @@ public void onCreate(Bundle savedInstanceState) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.lvExp), (v, windowInsets) -> {
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout());

// Apply the insets as a margin to the view so it doesn't overlap with status bar
ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
mlp.leftMargin = insets.left;
mlp.bottomMargin = insets.bottom;
mlp.rightMargin = insets.right;
// mlp.topMargin = insets.top;
v.setLayoutParams(mlp);

// Alternatively set the padding on the view itself.
// v.setPadding(0, 0, 0, 0);

// Return CONSUMED if you don't want want the window insets to keep passing down to descendant views.
// return windowInsets;
return WindowInsetsCompat.CONSUMED;
});

}
catch(Exception ex){
//http://stackoverflow.com/questions/26657348/appcompat-v7-v21-0-0-causing-crash-on-samsung-devices-with-android-v4-2-2
Expand Down

0 comments on commit b3aea4c

Please sign in to comment.