2017-10-18 1 views
0

私はスクロールビューに直接の子を1つだけ含めました。私はjavaファイルに以下のコードを追加しました。私はユーティリティメソッドを削除するとリストビューは完全に表示されていますが、内部つ以上のスクロールビューを持っている場合はscrollviewリストビューでスクロールビューが機能しない

 ScrollView sv_fragment_globe; 
     sv_fragment_globe = (ScrollView)rowView.findViewById(R.id.sv_fragment_globe); 
     sv_fragment_globe.smoothScrollTo(0,0); 
     Utility.setListViewHeightBasedOnChildren(holder.lv_globe); 

<ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:id="@+id/sv_fragment_globe" 
     android:fillViewport="true" 
     > 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="0dp" 
      android:orientation="vertical" 
      > 

      <ImageView 
       android:layout_width="fill_parent" 
       android:layout_height="200dp" 
       android:src="@drawable/home_hospital1" 
       android:id="@+id/iv_vp_globe" 
       android:scaleType="fitXY" 
       /> 


      <ListView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/lv_globe" 
       > 


      </ListView> 

    </LinearLayout> 

</ScrollView> 



</android.support.v4.widget.SwipeRefreshLayout> 
+0

スクロール可能なビューをネストするのは、アンチパターンです。あなたはたぶんスクロール戦闘の問題に終わるでしょう –

答えて

0

としてdoesntの仕事は、この

<android.support.v4.widget.SwipeRefreshLayout 
    android:id="@+id/swipe_refresh_layout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 
    <ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    > 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:weightSum="1" 
     > 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="200dp" 
      android:src="@android:drawable/home_hospital" 
      android:id="@+id/iv_vp_globe" 
      android:scaleType="fitXY" 
      /> 


     <ListView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/lv_globe" 
      android:layout_weight="1" 
      > 


     </ListView> 
    </LinearLayout> 
    </ScrollView> 
    </android.support.v4.widget.SwipeRefreshLayout> 
+0

それは動作しません –

+0

@VicChew更新されたXMLを試してください –

+0

全体のリストビューがきれいに出たが、スクロールビューは動作しません –

0

をお試しください任意のレイアウトであれば、親スクロール・ビューはスクロールするだけです。子のスクロール要素をスクロールするには、以下の手順に従います。

手順1: カスタムListViewを作成します。リストビューオブジェクトを初期化した後に以下の行を追加します

パブリッククラスExpandableHeightListViewリストビュー {

boolean expanded = false; 

public ExpandableHeightListView(Context context) 
{ 
    super(context); 
} 

public ExpandableHeightListView(Context context, AttributeSet attrs) 
{ 
    super(context, attrs); 
} 

public ExpandableHeightListView(Context context, AttributeSet attrs,int defStyle) 
{ 
    super(context, attrs, defStyle); 
} 

public boolean isExpanded() 
{ 
    return expanded; 
} 

@Override 
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) 
{ 
    // HACK! TAKE THAT ANDROID! 
    if (isExpanded()) 
    { 
     // Calculate entire height by providing a very large height hint. 
     // But do not use the highest 2 bits of this integer; those are 
     // reserved for the MeasureSpec mode. 
     int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); 
     super.onMeasure(widthMeasureSpec, expandSpec); 

     ViewGroup.LayoutParams params = getLayoutParams(); 
     params.height = getMeasuredHeight(); 
    } 
    else 
    { 
     super.onMeasure(widthMeasureSpec, heightMeasureSpec); 
    } 
} 

public void setExpanded(boolean expanded) 
{ 
    this.expanded = expanded; 
} 

}

ステップ2を拡張します。

lv_selected_time_zone.setExpanded(true);

関連する問題