【发布时间】:2020-09-02 09:27:42
【问题描述】:
我有这样的 xml 用于 RV 项目:
<?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:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/counter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="@drawable/dialog_background"
android:textColor="@color/colorAccent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/question"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="@drawable/dialog_background"
android:textColor="@color/gray_color"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/counter" />
<de.applicatione.jobs.jobbSeek.adapters.LollipopFixedWebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:fontFamily="@font/opensans_semibold"
android:labelFor="@id/webView"
android:nestedScrollingEnabled="true"
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/question" />
<EditText
android:id="@+id/user_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:autofillHints="@string/enter_your_answer_polls"
android:background="@drawable/polls_field"
android:fontFamily="@font/opensans_semibold"
android:hint="@string/enter_your_answer_polls"
android:inputType="text"
android:textColor="#666666"
android:textColorHint="@color/colorPrimary"
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/webView" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/answers_options"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="@drawable/dialog_background"
android:overScrollMode="never"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/user_input" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/question_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="20"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/answers_options">
<Button
android:id="@+id/prev_question"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="10"
android:text="@string/previous_question_polls"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/next_question"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="10"
android:background="@drawable/main_screen_btn"
android:text="@string/next_question_polls"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@id/prev_question"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
这是我的 RV xml:
<androidx.core.widget.NestedScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never"
android:descendantFocusability="blocksDescendants"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/divider">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/main_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never"
android:descendantFocusability="blocksDescendants"
android:visibility="gone" />
</androidx.core.widget.NestedScrollView>
问题是我没有从项目 xml 中看到我的按钮。当我用一些数据填充 RV 时,它们变得不可见。我检查了所有内容,但无法理解如何解决此问题。我很确定问题出在 xml 上,但我不明白它在哪里。我使用了布局检查器,我看到我在 RV 项中的 RV 下方的按钮,但我无法滚动并查看它们。也许我在xml中犯了任何错误?我认为问题可能在于固定 RV 大小或嵌套滚动并添加了以下代码:
!answersList.hasFixedSize()
answersList.isNestedScrollingEnabled = false
【问题讨论】:
标签: android android-layout android-recyclerview