-
-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
workaround issue with dispatching window insets on Android API < 30 (f…
…ixes #6030)
- Loading branch information
1 parent
4b30199
commit 524c029
Showing
2 changed files
with
29 additions
and
2 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
app/src/main/java/de/westnordost/streetcomplete/view/RelativeLayoutFix.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package de.westnordost.streetcomplete.view | ||
|
||
import android.content.Context | ||
import android.os.Build | ||
import android.os.Build.VERSION_CODES | ||
import android.util.AttributeSet | ||
import android.view.WindowInsets | ||
import android.widget.RelativeLayout | ||
|
||
class RelativeLayoutFix @JvmOverloads constructor( | ||
context: Context, | ||
attrs: AttributeSet? = null, | ||
defStyleAttr: Int = 0, | ||
) : RelativeLayout(context, attrs, defStyleAttr) { | ||
|
||
// always dispatch window insets to children, see #6030 | ||
override fun dispatchApplyWindowInsets(insets: WindowInsets): WindowInsets { | ||
if (Build.VERSION.SDK_INT >= VERSION_CODES.R) { | ||
return super.dispatchApplyWindowInsets(insets) | ||
} else { | ||
for (i in 0 until childCount) { | ||
getChildAt(i).dispatchApplyWindowInsets(insets) | ||
} | ||
return insets | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters