2016-03-09 38 views
1

我搜索很多關於scrollview的主題,它不滾動,但沒有人能解決我的問題:/ 如果有人可以幫我:) 每個listview打印一些人,當我做一個從我的服務器 請求通常當我滾動我的名單下來第二個列表中出現,但它不Scrollview不滾動2列表視圖

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/selector_for_background_white" 
    android:orientation="vertical"> 

    <ScrollView 
     android:id="@+id/scrollView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@drawable/selector_for_background_white" 
     android:fillViewport="true"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <LinearLayout 
       android:id="@+id/layoutScrollResult" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical"> 

       <RelativeLayout 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:background="@drawable/selector_for_background_white"> 

        <LinearLayout 
         android:id="@+id/layout2" 
         android:layout_width="match_parent" 
         android:layout_height="40dp" 
         android:orientation="horizontal"> 

         <com.whask.whask.utils.font.FontTextView 
          android:id="@+id/text_hot" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_centerVertical="true" 
          android:layout_gravity="center" 
          android:layout_marginLeft="10dp" 
          android:layout_marginStart="10dp" 
          android:background="@android:color/transparent" 
          android:text="5 HOT" 
          android:textSize="@dimen/abc_text_size_medium_material" 
          app:font="Neo-Sans-Std-Medium.otf"/> 
        </LinearLayout> 


        <ListView 
         android:id="@+id/result_whask_listview_view" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_below="@+id/layout2"> 
        </ListView> 

        <LinearLayout 
         android:id="@+id/layout3" 
         android:layout_width="match_parent" 
         android:layout_height="40dp" 
         android:layout_below="@+id/result_whask_listview_view" 
         android:orientation="horizontal"> 

         <com.whask.whask.utils.font.FontTextView 
          android:id="@+id/text_not" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_centerVertical="true" 
          android:layout_gravity="center" 
          android:layout_marginLeft="10dp" 
          android:layout_marginStart="10dp" 
          android:background="@android:color/transparent" 
          android:text="2 NOT" 
          android:textSize="@dimen/abc_text_size_medium_material" 
          app:font="Neo-Sans-Std-Medium.otf"/> 
        </LinearLayout> 

        <ListView 
         android:id="@+id/result_whask_listview_view_no" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_below="@+id/layout3" 
         android:background="@color/my_whask_white_color"> 
        </ListView> 

       </RelativeLayout> 

      </LinearLayout> 

     </LinearLayout> 

    </ScrollView> 

</LinearLayout> 
+0

你不應該使用scrollview與listview作爲listview有它自己的滾動。而不是使用列表視圖以線性或框架佈局膨脹項目。通過這種方式,您可以輕鬆實現包裝內容功能,因爲listview無法正確使用換行內容 –

+0

是否需要在scrollview中滾動listview? @Mavrick RMx的 – RushDroid

+0

如果我不使用滾動型,我的2 FontTextView不會滾動,我的第二列表視圖留在底部,我不能看到這些元素,我需要我的FontTextView滾動太@VivekMishra –

回答

1

切勿使用ListViewScrollViewListView本身有一個滾動屬性,你不必使用另一個ScrollView來滾動它。改爲使用LinearLayout

1

列表視圖有自己的滾動特性,所以不要,如果要滾動列表視圖內滾動型不僅僅是做這樣滾動視圖中使用... 感謝

1

ListView result_whask_listview_view; 
result_whask_listview_view = (ListView)findViewById(R.id.result_whask_listview_view); 

result_whask_listview_view.setOnTouchListener(new ListView.OnTouchListener() { 
        @Override 
        public boolean onTouch(View v, MotionEvent event) { 
         int action = event.getAction(); 
         switch (action) { 
          case MotionEvent.ACTION_DOWN: 
           // Disallow ScrollView to intercept touch events. 
           v.getParent().requestDisallowInterceptTouchEvent(true); 
           break; 

          case MotionEvent.ACTION_UP: 
           // Allow ScrollView to intercept touch events. 
           v.getParent().requestDisallowInterceptTouchEvent(false); 
           break; 
         } 

         // Handle ListView touch events. 
         v.onTouchEvent(event); 
         return true; 
        } 
       }); 

這樣你可以在scrollview裏面滾動listview。

希望它可以幫助你:)