【发布时间】: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