#java #android
#java #Android
Вопрос:
Я создаю простое приложение для Android — RecyclerView, две кнопки и EditText. Все в порядке, кроме EditText — он не отображается в эмуляторе, но отображается в режиме конструктора. Я пробовал разные конфигурации — не повезло.
Любая помощь будет принята с благодарностью. Заранее спасибо, Ad.
Код:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="@ id/rvA"
android:layout_width="411dp"
android:layout_height="652dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@ id/button"
android:layout_width="88dp"
android:layout_height="0dp"
android:text="Button"
android:onClick="fur"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<Button
android:id="@ id/button3"
android:layout_width="88dp"
android:layout_height="48dp"
android:onClick="ed"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@ id/button" />
<EditText
android:id="@ id/et1"
android:layout_width="200dp"
android:layout_height="50dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@ id/button3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@ id/rvA" />
</androidx.constraintlayout.widget.ConstraintLayout>
Комментарии:
1. Можете ли вы удалить ` app:layout_constraintTop_toBottomOf=»@ id/ rvA»` из
EditText
проверки и?
Ответ №1:
Попробуйте установить высоту представления recycler 0dp и снизу вверх кнопок или редактировать текст следующим образом:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="@ id/rvA"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@ id/button"/>
<Button
android:id="@ id/button"
android:layout_width="88dp"
android:layout_height="48dp"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<Button
android:id="@ id/button3"
android:layout_width="88dp"
android:layout_height="48dp"
android:text="Button3"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@ id/button" />
<EditText
android:id="@ id/et1"
android:layout_width="200dp"
android:layout_height="50dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@ id/button3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@ id/rvA" />
</androidx.constraintlayout.widget.ConstraintLayout>
Я пробую это на эмуляторе, и edittext отображается нормально.
Комментарии:
1. Рад, что я помог вам @Ady