mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-04 03:06:41 -04:00
Fixed extra space on the webview top if the webview is not atteched to any view
This commit is contained in:
parent
17cbcf082d
commit
a3de2a25c7
@ -686,17 +686,20 @@ abstract class CoreReaderFragment :
|
|||||||
*/
|
*/
|
||||||
protected open fun setTopMarginToWebViews(topMargin: Int) {
|
protected open fun setTopMarginToWebViews(topMargin: Int) {
|
||||||
for (webView in webViewList) {
|
for (webView in webViewList) {
|
||||||
webView.parent?.let {
|
if (webView.parent == null) {
|
||||||
// Ensure that the web view has a parent before modifying its layout parameters
|
// Ensure that the web view has a parent before modifying its layout parameters
|
||||||
// This check is necessary to prevent adding the margin when the web view is not attached to a layout
|
// This check is necessary to prevent adding the margin when the web view is not attached to a layout
|
||||||
// Adding the margin without a parent can cause unintended layout issues or empty
|
// Adding the margin without a parent can cause unintended layout issues or empty
|
||||||
// space on top of the webView in the tabs adapter.
|
// space on top of the webView in the tabs adapter.
|
||||||
|
val frameLayout = FrameLayout(requireActivity())
|
||||||
|
// Add the web view to the frame layout
|
||||||
|
frameLayout.addView(webView)
|
||||||
|
}
|
||||||
val layoutParams = webView.layoutParams as FrameLayout.LayoutParams?
|
val layoutParams = webView.layoutParams as FrameLayout.LayoutParams?
|
||||||
layoutParams?.topMargin = topMargin
|
layoutParams?.topMargin = topMargin
|
||||||
webView.requestLayout()
|
webView.requestLayout()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected fun startAnimation(view: View?, @AnimRes anim: Int) {
|
protected fun startAnimation(view: View?, @AnimRes anim: Int) {
|
||||||
view?.startAnimation(AnimationUtils.loadAnimation(view.context, anim))
|
view?.startAnimation(AnimationUtils.loadAnimation(view.context, anim))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user