【问题标题】:ConstraintLayout & BottomNavigationView, fragment and controls appear underneath. GoogleMaps v3 padding?ConstraintLayout & BottomNavigationView,fragment和控件出现在下方。 GoogleMaps v3 填充?
【发布时间】:2021-03-24 20:32:37
【问题描述】:

ConstraintLayout & BottomNavigationView,fragment 和控件出现在下方。 GoogleMaps v3 填充?

我的术语在这里可能不正确,这可能是我找不到我遗漏的内容的原因。 鉴于我对 XML 的看法:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/nav_view"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="0dp"
        android:layout_marginEnd="0dp"
        android:background="?attr/colorPrimary"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:menu="@menu/bottom_nav_menu" />

    <fragment
        android:id="@+id/nav_host_fragment"
        android:name="androidx.navigation.fragment.NavHostFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:defaultNavHost="true"
        app:layout_constraintBottom_toTopOf="@id/nav_view"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:navGraph="@navigation/mobile_navigation" />
</androidx.constraintlayout.widget.ConstraintLayout>

根据用户的操作,我的nav_host_fragment 可能有一个片段,它是另一个ConstraintLayout,它有一个或两个操作按钮被限制在底部,我明白了:

尽我所能进行研究,我看到了两个修复。将app:layout_constrainedHeight="true" 添加到id/nav_host_fragment将同一片段的layout_widthlayout_height 更改为“0dp”。这有效,但不适用于圆角,因为有“空白空间”:

注意黑角。还有谷歌的一点版权。有没有办法告诉 GoogleMaps 片段(或其父 ConstraintLayout)“填充”自身的底部,以便黑色圆角不是黑色,并且所需的 Goog 徽标和 ym 操作按钮不会隐藏在下面?

【问题讨论】:

    标签: android google-maps android-constraintlayout material-components-android


    【解决方案1】:

    您应该调整地图的padding 以将徽标向上移动,我认为这可以解决您的问题

    地图填充允许您在必要时重新定位这些元素。如果 您在地图底部显示自定义 UI,将填充添加到 地图底部,以便始终显示徽标和法律声明 可见

    【讨论】:

    • 啊,应该可以,谢谢!有什么方法(最好在 XML 中)来获得所需的 madding 的高度?
    • 我不知道(至少对于 xml)
    猜你喜欢
    • 1970-01-01
    • 2017-11-20
    • 1970-01-01
    • 1970-01-01
    • 2020-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多