-1

I have a Fragment in ViewPager which can be scrolled right and left. But every has ScollView with TextView. This TextView can have a lot of text (code-generated), so I want to be able to scroll it vertically, but if I toutch the device, fragments are more important, so I can only swipe it horizontally. Is any way to fix it? my layout:

<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>
Andret2344
  • 653
  • 1
  • 12
  • 33
  • What do you mean by "Fragment can be scrolled right and left"? Is the `Fragment` inside a `ViewPager`? – PPartisan Nov 07 '15 at 19:06
  • @PPartisan yes, it's inside ViewPager – Andret2344 Nov 07 '15 at 19:20
  • It's possible the `ViewPager` is intercepting all swipe events in that case. You could test this by creating your own `ViewPager` class, overriding `onInterceptTouchEvent()`/`onTouchEvent()` and see what happens with up and down swipes. I'll test it myself when I get the chance. – PPartisan Nov 07 '15 at 19:28
  • @PPartisan it isn't thuth, in another place I have viewpager that contains fragment, every of them contains gridview, and this can be simply scrolled vertically, either viewpager can be horizontally. Problem isn't occurring – Andret2344 Nov 07 '15 at 20:08
  • It's happen in all devices snd SDK's? what wrap the fragment itself? – blay Feb 16 '16 at 09:28

2 Answers2

1

try this code if run rewrite some parameters for your own.

<ScrollView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/scrollView2"
            android:scrollIndicators="right">

            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:paddingRight="8dp">

                <FrameLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:paddingTop="20dp"
                    android:scrollIndicators="right">


                <FrameLayout>

                </FrameLayout>

            </FrameLayout>
        </ScrollView>
Parad0X
  • 3,634
  • 2
  • 12
  • 23
-1

edit :

you must modify scrollview height. wrap_content -> match_parent and you can add this attributes

android:focusable="true"
android:focusableInTouchMode="true"
android:descendantFocusability="beforeDescendants"

edit2:

<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="match_parent" // edit
android:focusable="true" // add
android:focusableInTouchMode="true" // add
android:descendantFocusability="beforeDescendants" // add
android:orientation="vertical"
tools:context="${relativePackage}.${activityClass}" >

// ... 

</LinearLayout>
LEETAEJUN
  • 186
  • 9