У меня есть фрагмент в ViewPager, который можно прокручивать вправо и влево. Но каждый имеет ScollView с TextView. Этот TextView может иметь много текста (сгенерированный кодом), поэтому я хочу, чтобы он мог прокручивать его по вертикали, но если я задействую устройство, фрагменты важнее, поэтому я могу только прокручивать его по горизонтали. Есть ли способ исправить это? мой макет:Android - прокрутка ScrollView в фрагменте невозможна
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/colectionday_relative_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#123456"
android:orientation="vertical"
tools:context="${relativePackage}.${activityClass}" >
<RelativeLayout
android:id="@+id/colectionday_relative_top"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/rounded_layout_top" >
<TextView
android:id="@+id/colectionday_text_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginLeft="5dp"
android:textSize="@dimen/day_date_text" />
<ImageView
android:id="@+id/colectionday_image_favourite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:contentDescription="@string/caution"
android:src="@drawable/star_gray"
android:visibility="visible" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/colecionday_relative_content"
android:layout_width="match_parent"
android:layout_height="fill_parent" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/colectionday_button_share"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="15dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:fastScrollAlwaysVisible="true"
android:fastScrollEnabled="true" >
<TextView
android:id="@+id/colectionday_text_holidays"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fastScrollAlwaysVisible="true"
android:fastScrollEnabled="true"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF"
android:textSize="@dimen/day_holiday_text" />
</ScrollView>
<Button
android:id="@+id/colectionday_button_share"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/colectionday_adview_bottom_dark"
android:layout_centerHorizontal="true"
android:text="@string/share"
android:textColor="#FFFFFF"
android:textSize="35sp" />
<com.google.android.gms.ads.AdView
android:id="@+id/colectionday_adview_bottom_dark"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-1234567890/1234567890" />
<com.google.android.gms.ads.AdView
android:id="@+id/colectionday_adview_bottom_light"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-1234567890/1234567890"
android:visibility="invisible" />
</RelativeLayout>
</LinearLayout>
Что вы имеете в виду под "Фрагмент можно прокручивать вправо и влево"? Является ли «Фрагмент» внутри «ViewPager»? – PPartisan
@PPartisan Да, это внутри ViewPager – Andret
Возможно, что «ViewPager» перехватывает все события салфетки в этом случае. Вы можете протестировать это, создав свой собственный класс «ViewPager», переопределив 'onInterceptTouchEvent()'/'onTouchEvent()' и посмотрим, что происходит с прокруткой вверх и вниз. Я испытаю это сам, когда у меня появится такая возможность. – PPartisan