Android按钮需要点击两次才能激活

时间:2019-09-23 16:51:54

标签: android

所以我有一个带有回收站视图的片段,并且当用户点击其中一个订单项时,将出现一个底页。

底页是线性布局,由线性布局和嵌套滚动视图组成。在嵌套滚动视图内,我有两个线性布局(显然是由另一个线性布局包裹的,因为在嵌套滚动视图下只能有一个孩子)。

我的问题是在嵌套的滚动视图中,我有一个按钮,由于某种原因,我不得不点按两次以触发回调,我猜测这与焦点有关。我已经尝试在整个底部工作表视图层次结构上进行requestFocus()调用,但是问题仍然存在。有任何线索吗?

这是底部工作表的xml:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/bottom_sheet"
    android:background="@android:color/white"
    app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
    app:behavior_hideable="true"
    app:behavior_peekHeight="?attr/actionBarSize"
    android:elevation="8dp"
    android:clickable="true"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:focusable="true">

    <include layout="@layout/bottom_sheet_bar"
        android:id="@+id/bottom_sheet_bar" />

    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/bottom_sheet_nested_scroll">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <include layout="@layout/bottom_sheet_main_content"
                android:id="@+id/bottom_sheet_2_main_content"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.09"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="parent" />

            <include layout="@layout/bottom_sheet_buttons"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="1.0"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/bottom_sheet_2_main_content" />

        </LinearLayout>

    </androidx.core.widget.NestedScrollView>


</LinearLayout>

以下是该片段的xml:

<androidx.coordinatorlayout.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/swipe_refresh_job_request">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/job_request_recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" />

    </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/empty_list"
        android:visibility="invisible"
        android:id="@+id/empty_placeholder_image_id"
        android:scaleType="centerCrop"/>

    <TextView
        android:layout_marginTop="32dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textAppearance="@style/TextAppearance.AppCompat.Display1"
        android:textAlignment="center"
        android:id="@+id/empty_load_placeholder_text_id"
        android:visibility="invisible"
        android:text="Sorry, please check back later!"
        />

    <include layout="@layout/bottom_sheet"/>

    <ProgressBar
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:visibility="invisible"
        android:id="@+id/job_request_progress_bar"
        android:layout_gravity="center"/>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

0 个答案:

没有答案