Kanten-zu-Rand in Android-Bibliotheken

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Kanten-zu-Rand in Android-Bibliotheken

by Guest » 05 Feb 2025, 00:40

Ich habe eine Video-Player-Bibliothek und tritt derzeit Probleme mit der erzwungenen Edge-to-Edge-Ebene auf. p> Ich möchte dieses Problem lösen, ohne die Transsitive Abhängigkeit von Androidx einzubeziehen. und ergreifen Sie sonst keine Maßnahmen.

Code: Select all

public static void setEdgeToEdgeInsets(View view) {
Context viewContext = view.getContext();
if(viewContext instanceof Activity){
int targetSdk = viewContext.getApplicationInfo().targetSdkVersion;
if (Build.VERSION.SDK_INT >= 35 && targetSdk>=35) {
((Activity)viewContext).getWindow().getDecorView().setOnApplyWindowInsetsListener((v, windowInsets) -> {
Insets in = windowInsets.getInsets(WindowInsets.Type.systemBars());
view.setPadding(in.left, in.top, in.right, in.bottom);
return windowInsets;
});
}
}
}

Top