【问题标题】:Bottom Sheet dont appear , Staying behind the ArFragment in Android底部工作表没有出现,留在 Android 的 Fragment 后面
【发布时间】:2019-02-21 06:09:09
【问题描述】:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <fragment
        android:id="@+id/fragment"
        android:name="com.project.testapplication.WritingArFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:background="@android:color/darker_gray"
        android:minHeight="?attr/actionBarSize"
        android:theme="?attr/actionBarTheme">

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/up"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="38dp"
            android:clickable="true"
            app:backgroundTint="@android:color/transparent"
            app:srcCompat="@drawable/ic_arrow_upward_white_24dp" />

    </android.support.v7.widget.Toolbar>


    <android.support.v4.widget.NestedScrollView
        android:id="@+id/nestedScroll"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:fillViewport="true"
        app:behavior_hideable="true"
        app:behavior_peekHeight="0dp"
        app:layout_behavior="@string/bottom_sheet_behavior">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            <include layout="@layout/bottom_sheet"></include>
        </LinearLayout>
    </android.support.v4.widget.NestedScrollView>

</android.support.design.widget.CoordinatorLayout>

这部分是我的 ui 界面 action_main.xml,我想在我选择的场景中添加 3D 对象。为此,我决定使用模态底页。我单击按钮并打开嵌套滚动视图,而不是选择对象,然后它再次下降。但是当我单击向上 FAB 按钮时,嵌套滚动视图停留在片段后面(Java 部分运行良好),因此它不会出现在屏幕上。我正在使用 ArFragment (ar.sceneform:plugin1.6.0)。我找不到我的错在哪里。谢谢:)

FloatingActionButton openBS = (FloatingActionButton) findViewById(R.id.up);

        View nestedScroll = (View) findViewById(R.id.nestedScroll);

        mBottomSheetBehaviour = BottomSheetBehavior.from(nestedScroll);

        openBS.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mBottomSheetBehaviour.setState(BottomSheetBehavior.STATE_EXPANDED);
            }
        }); 

这是 MainActivity.java

【问题讨论】:

  • 尝试在底部工作表中添加高程。有时海拔会导致此问题。
  • 将它从对于bottomSheetView 不需要的nestedScrollView 中取出。包含nestedScrollView 的唯一原因是,如果您将recyclerView 嵌套在底部表中,因为滚动交互被底部表吃掉了,但这也很糟糕,因为它没有经过优化。 NestedScrollViews 将子项变成静态绘制资源,因此回收视图在其中毫无意义,但这不是重点。

标签: android android-layout arcore sceneform


【解决方案1】:

请按照本教程了解完美工作的底页

https://www.androidhive.info/2017/12/android-working-with-bottom-sheet/

【讨论】:

  • 感谢您的分享 :) 但底页运行良好。我正在尝试将它与 ARCore ArFragment 一起使用。因此底片不会出现
【解决方案2】:

我在使用导航视图时遇到了同样的问题。确实菜单出现在片段后面。你可以试试 android:elevation

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-17
    • 2020-10-06
    • 1970-01-01
    • 1970-01-01
    • 2020-12-16
    相关资源
    最近更新 更多