1

Twitter SDKをリストフラグメントに実装しました。これは、ツイッターのように無制限のスクロールを持っています。しかし、私はこのフラグメントをscrollview layoutに追加しようとすると、scrollviewtwitter fragmentを無効にします。フラグメント内のスクロールを追加する方法

public class TwitterFragment extends ListFragment { 
    public static TwitterFragment newInstance() { 
     return new TwitterFragment(); 
    } 

レイアウト

<TextView 
     android:id="@id/android:empty" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:gravity="center_horizontal|center_vertical" 
     android:text="No Tweets" /> 

    <ListView 
     android:id="@id/android:list" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_marginTop="50dp" 
     android:layout_weight="1" 
     android:divider="#e1e8ed" 
     android:dividerHeight="1dp" 
     android:drawSelectorOnTop="false" /> 
</LinearLayout> 

今私は別のアクティビティでこのフラグメントを追加します。 MainActivityには既にスクロール表示があります。この断片をそこに追加すると、twitter断片のスクロールが消えてしまいます。私はいろいろ試しましたが、目標を達成できませんでした。

小さな断片にも同じ無制限のスクロールが必要です。

これは私のMainActivityコードです。

<RelativeLayout 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:id="@+id/content_users_feedback" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="com.myapp.app.usersreviews.reviews" 
    android:background="@drawable/users_bg" 
    tools:showIn="@layout/activity_user_reviews"> 



    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fillViewport="true" 
     android:isScrollContainer="false" 
     android:id="@+id/scroll_view" 
     android:layout_below="@+id/sv_users" 
     > 


     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical" 
      > 


      <!-- USER DATA--> 
      <include layout="@layout/users_data_list" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:id="@+id/layout_data" 

       /> 



      <!-- TWITTER--> 

      <TextView 
       android:id="@+id/textView8" 
       android:layout_width="match_parent" 
       android:layout_height="33.62dp" 
       android:background="#054F92" 
       android:gravity="center_vertical" 
       android:text="\@tweets" 
       android:textColor="@android:color/white" 
       android:textSize="16sp" 
       android:paddingLeft="15dp" 
       android:textStyle="normal|bold" /> 


       <fragment 
        android:id="@+id/cart_twitter_fragment" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_marginTop="-50dp" 
        android:nestedScrollingEnabled="true" 
        class="com.myapp.app.TwitterFragment" 
        tools:layout="@layout/fragment_twitter" /> 


      <!-- TWITTER --> 


     </LinearLayout> 

    </ScrollView> 

</RelativeLayout> 
+0

ScrollViewのインスタンスを作成する必要がないときに、ユーザデータリストが含まれていませんスクロールする必要があるほど多くのデータ – clownba0t

+0

@ clownba0t、はい、それは多くのデータを持っています、私は質問にすべてのビューを追加していません – Kirmani88

+0

私の理解は、少なくとも部分的には、ScrollView'sの入れ子は、スワイプジェスチャーを処理する必要があります。この問題に直面しているようです。データの表示方法を変更することをおすすめします。あなたの活動レイアウトで 'ScrollView'を動かして、ユーザデータリストだけをラップするようにしてください。あなたは2つのスクロールレイアウトを持っていますが、それらはネストされていません。次に、フラグメントの幅、高さ、重さなどを設定し、目的のUIを実現するようにスクロールビューをスクロールできるようにします。 – clownba0t

答えて

2

あなたが全体のレイアウトをラップfragment_layout.xmlScrollViewを追加することができます(ScrollViewは、通常、全体のレイアウトがfragment_layout.xmlで定義され、この場合には、一人の子供を持っています)。 View次いでレイアウトインフレータによって通常生成される

fragment.java:ScrollViewScrollViewfragment_layout.xmlの次の例で

View view = inflater.inflate(R.layout.fragment_layout, container, false); 
return view; 

は、二つTextViewsが含まConstraintLayoutラップ

fragment_layout.xml:

<?xml version="1.0" encoding="utf-8"?> 

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/scrollView" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true"> 

<android.support.constraint.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="com.example.ralf.gpstelephony.TelephonyManagerFragment"> 


    <TextView 
     android:id="@+id/TextView_1" 
     android:layout_width="match_parent" 
     android:layout_height="600dp" 
     android:text="@string/string1" 
     app:layout_constraintTop_toBottomOf="parent" 
     app:layout_constraintLeft_toLeftOf="parent" 
     android:layout_marginTop="10dp" 
     android:layout_marginLeft="10dp" /> 

<TextView 
     android:id="@+id/TextView_2" 
     android:layout_width="match_parent" 
     android:layout_height="600dp" 
     android:text="@string/string2" 
     app:layout_constraintTop_toBottomOf="@id/TextView1" 
     app:layout_constraintLeft_toLeftOf="@id/TextView1" 
     android:layout_marginTop="10dp" 
     android:layout_marginLeft="0dp" /> 

</android.support.constraint.ConstraintLayout> 

</ScrollView> 

LayoutInflaterは、すべての作業を行い、この方法を使用すると、1ちょうど確認するfragment.javaに(XMLベースの方法)

関連する問題