LuckSiege / LuckSiege/PictureSelector

Edge-to-Edge android15导航栏遮挡内容适配

Open
#3,000 6 comments 14 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
13.6k
Forks
3.1k
PR merge metrics
No merged PRs in 30d

Description

可以在application中监听给android.R.id.content添加padding解决三方库未适配的问题

```
private void registerActivityLifecycleCallbacks() {
registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
if (activity instanceof PictureSelectorSupporterActivity ||
activity instanceof PictureSelectorTransparentActivity ||

) {
//your idea
NavigationBarUtil.INSTANCE.applyNavigationBarPadding(activity);
}
}
}

object NavigationBarUtil {

val SUPPORT_EDGE_TO_EDGE_VERSION = Build.VERSION_CODES.VANILLA_ICE_CREAM//15+
@JvmField
val isEdgeToEdgeSupported = Build.VERSION.SDK_INT >= SUPPORT_EDGE_TO_EDGE_VERSION

/**
* 适配底部导航栏 : 给根布局添加底部导航栏的padding
*/
fun applyNavigationBarPadding(activity: Activity) {
if (isEdgeToEdgeSupported) {
//Edge-to-Edge 模式适配
val rootView = activity.window.decorView.findViewById(android.R.id.content)
if (rootView != null) {
applyNavigationBarInsets(rootView)
}
}
}

/**
* 给view添加一个底部导航栏高度的padding
*/
fun applyNavigationBarInsets(view: View) {
val initialPaddingBottom = view.paddingBottom
ViewCompat.setOnApplyWindowInsetsListener(view) { v: View, insets: WindowInsetsCompat ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(
v.paddingLeft,
v.paddingTop,
v.paddingRight,
initialPaddingBottom + systemBars.bottom
)
insets
}
}
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the application ActivityLifecycleCallbacks entry point and the PictureSelectorSupporterActivity and PictureSelectorTransparentActivity classes mentioned in the issue. Review the proposed NavigationBarUtil handling around android.R.id.content and Android 15 edge-to-edge behavior, then verify that affected content is no longer obscured by the navigation bar.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.