У меня есть определенные виджеты в LinearLayout
, который является потомком ScrollView
.Проблема в том, что первый виджет в этом случае, виджет с именем «Заголовок 1» не виден, он выходит за пределы размера экрана, как видно на этом изображении,
Я попробовал следующее, но все равно он не показывает мой заголовок 1.
Добавлен атрибут android:fillViewport="true"
в ScrollView
, но он не работает.
Добавлен атрибут layout_gravity
(center_horizontal | center_vertical
), но он не работал.
Этот вопрос был специфичен для дизайна ОП Android ScrollView fillViewport не работает и мало помогает.
Примечание: Я хочу, чтобы виджет был виден без использования каких-либо атрибутов полей / отступов.
Код,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
>
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/view_pager"
android:fillViewport="true"
android:focusableInTouchMode="true"
app:layout_constraintBottom_toTopOf="@+id/tabLayout"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="10dp"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:gravity="center"
android:background="@color/green"
android:text="Title 1"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:gravity="center"
android:background="@color/green"
android:layout_marginTop="20dp"
android:text="Title 2"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:gravity="center"
android:background="@color/green"
android:layout_marginTop="20dp"
android:text="Title 3"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:gravity="center"
android:background="@color/green"
android:layout_marginTop="20dp"
android:text="Title 4"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:gravity="center"
android:background="@color/green"
android:layout_marginTop="20dp"
android:text="Title 5"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:gravity="center"
android:background="@color/green"
android:layout_marginTop="20dp"
android:text="Title 6"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:gravity="center"
android:background="@color/green"
android:layout_marginTop="20dp"
android:text="Title 7"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:gravity="center"
android:background="@color/green"
android:layout_marginTop="20dp"
android:text="Title 8"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:gravity="center"
android:background="@color/green"
android:layout_marginTop="20dp"
android:text="Title 9"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:gravity="center"
android:background="@color/green"
android:layout_marginTop="20dp"
android:text="Title 10"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:gravity="center"
android:background="@color/green"
android:layout_marginTop="20dp"
android:text="Title 11"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:gravity="center"
android:background="@color/green"
android:layout_marginTop="20dp"
android:text="Title 12"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:gravity="center"
android:background="@color/green"
android:layout_marginTop="20dp"
android:text="Title 13"
/>
</LinearLayout>
</ScrollView>
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
style="@style/tabLayoutStyle"
app:layout_constraintBottom_toBottomOf="parent"
/>
</android.support.constraint.ConstraintLayout>
</LinearLayout>
РЕДАКТИРОВАТЬ 1
Изменена высота LinearLayout (Inside scrollview) с match_parent
до wrap_content
, но по-прежнему нетт работа.