Я не можу прокрутити екран вниз, щоб переглянути дані в розділі "Відповідає:". Як я можу зробити макет прокручуваним?

Я не можу прокрутити екран вниз, щоб переглянути дані в розділі "Відповідає:". Як я можу зробити макет прокручуваним?

Відповіді:
Просто оберніть все це всередині ScrollView:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- Here you put the rest of your current view-->
</ScrollView>
Як сказав Девід Хедлунд, ScrollView може містити лише один предмет ... тож, якщо у вас було щось подібне:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- bla bla bla-->
</LinearLayout>
Ви повинні змінити його на:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- bla bla bla-->
</LinearLayout>
</ScrollView>
Для використання режиму прокрутки разом із відносним макетом:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"> <!--IMPORTANT otherwise backgrnd img. will not fill the whole screen -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/background_image"
>
<!-- Bla Bla Bla i.e. Your Textviews/Buttons etc. -->
</RelativeLayout>
</ScrollView>
Просто оберніть все це всередині ScrollView
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.ruatech.sanikamal.justjava.MainActivity">
<!-- Here you put the rest of your current view-->
</ScrollView>
Якщо ви навіть не отримали прокрутки після того, як написали вище ...
Встановіть android:layout_height="250dp"або ви можете сказати, xdpде xможе бути будь-яке числове значення.
Так, це дуже просто. Просто помістіть свій код всередину цього:
<androidx.core.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
//YOUR CODE
</androidx.core.widget.NestedScrollView>
ScrollViewможе містити лише одну дитину, тому, якщо у вас є багато переглядів, вам потрібно обернути їх в одну групу переглядів (скажімо aLinearLayout)