1

おはようございます!Xamarin.Android:ListViewがコーディネーターレイアウトとCollapsingToolbarLayoutで正しくスクロールしない

私のアプリではスクロールの問題に直面しています。コーディネーター・レイアウトとリストビューがあります。私はリストビューをスクロールするとトップレイアウトを崩壊させたい。 これはNestedScrollViewなしでは不可能であることがわかりましたので、追加しました。

私がスクロールすると、コーディネーターのレイアウトだけがスクロールしてしまうという問題があります。私はダウンにスクロールすると

例として

、リストビューはそのように貼り付けられている:

enter image description here

私はまた私のListviewmatch_parentへのlayout_heightを設定しようとしたが、それは何も変更はありません。

main.xml

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/main_content" 
    android:fitsSystemWindows="true" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/ActionBarNoShadowLight" 
     android:fitsSystemWindows="true" 
     app:elevation="0dp"> 
     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/collapsing_toolbar" 
      android:layout_height="match_parent" 
      android:layout_width="match_parent" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed" 
      app:contentScrim="?attr/colorPrimary" 
      app:expandedTitleMarginStart="48dp" 
      app:expandedTitleMarginEnd="64dp" 
      android:fitsSystemWindows="true"> 
      <ImageView 
       android:id="@+id/mainImage" 
       android:layout_width="175dp" 
       android:layout_height="175dp" 
       android:layout_marginTop="50dp" 
       android:layout_alignParentTop="true" 
       android:layout_centerHorizontal="true" 
       android:scaleType="fitCenter" 
       app:srcCompat="@drawable/ic_document" 
       android:fitsSystemWindows="true" 
       app:layout_collapseMode="parallax" /> 
      <android.support.v7.widget.Toolbar 
       android:id="@+id/edit_toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       android:background="@color/BackgroundWhite" 
       app:layout_collapseMode="pin" 
       app:layout_scrollFlags="scroll|enterAlways" 
       app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 
     </android.support.design.widget.CollapsingToolbarLayout> 
    </android.support.design.widget.AppBarLayout> 
    <android.support.v4.widget.NestedScrollView 
     android:id="@+id/scroll" 
     android:layout_width="match_parent" 
     android:layout_height="fill_parent" 
     android:clipToPadding="false" 
     android:scrollbars="none" 
     android:fillViewport="true" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 
     <FrameLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" > 
      <ListView 
       android:id="@+id/lstTask" 
       android:layout_height="match_parent" 
       android:layout_width="fill_parent" 
       android:nestedScrollingEnabled="true" 
       android:layout_marginLeft="8dp" 
       android:layout_marginRight="8dp" 
       android:divider="@null" 
       /> 
      <ImageView 
       android:id="@+id/empty" 
       android:layout_height="200dp" 
       android:layout_width="200dp" 
       android:layout_marginTop="50dp" 
       android:scaleType="fitCenter" 
       android:gravity="center" 
       android:layout_alignParentTop="true" 
       android:layout_centerHorizontal="true" 
       app:srcCompat="@drawable/bg_notasks" /> 
     </FrameLayout> 
    </android.support.v4.widget.NestedScrollView> 
    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fabAdd" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="end|bottom" 
     android:layout_margin="@dimen/fab_margin" 
     android:src="@drawable/ic_plus" /> 
</android.support.design.widget.CoordinatorLayout> 

おかげで、あなたの将来の助け、 クレマンのためにたくさん:

は、ここに私のコードです。

答えて

0

あなたは、あなたがする必要があるあなたのlistViewを初期化コード内

<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:id="@+id/ll_pro_profile_reviews" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@color/white" 
android:orientation="vertical" 
app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

<com.vanitee.services.home.customer.shops.detail.reviews.NonScrollExpandableListView 
    android:id="@+id/rcv_pro_profile_reviews" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/spacing_8"/> 

</android.support.v4.widget.NestedScrollView> 

そして最後にレイアウト動作を追加

public class NonScrollListView extends ListView{ 

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

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

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

@Override 
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 
    int heightMeasureSpec_custom = MeasureSpec.makeMeasureSpec(
      Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); 
    super.onMeasure(widthMeasureSpec, heightMeasureSpec_custom); 
    ViewGroup.LayoutParams params = getLayoutParams(); 
    params.height = getMeasuredHeight(); 
} 
} 

以下のようにそして、あなたのxmlNonScrollListViewクラスを作成します。入れ子スクロールを無効にする

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 
    listView.setNestedScrollingEnabled(false); 
} else { 
    ViewCompat.setNestedScrollingEnabled(listView, false); 
} 
+0

おかげで、私はC#のに変換しようとするでしょう、それは私がクレマンポワレ@ Javaの –

0

はちょうどあなたが、C#にAyush Khareのコードを変換するために、これはあなたを助けることができれば、あなたは @Ayush Khareの答えをマークすることができ助けます。

public class NonScrollListView : ListView 
{ 
    public NonScrollListView(Context context) : base(context) 
    { 
    } 

    public NonScrollListView(Context context, IAttributeSet attrs) : base(context, attrs) 
    { 
    } 

    public NonScrollListView(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle) 
    { 
    } 

    protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec) 
    { 
     int heightMeasureSpec_custom = MeasureSpec.MakeMeasureSpec(Integer.MaxValue >> 2, MeasureSpecMode.AtMost); 
     base.OnMeasure(widthMeasureSpec, heightMeasureSpec); 

     ViewGroup.LayoutParams params2 = LayoutParameters; 
     params2.Height = MeasuredHeight; 
    } 
} 

無効にネストされたスクロール:答えを

if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop) 
{ 
    listView.NestedScrollingEnabled = false; 
} 
else 
{ 
    ViewCompat.SetNestedScrollingEnabled(listView, false); 
} 
+0

には本当に新しいですと私のための一種の複雑ですあなたの問題を解決しましたか? –

関連する問題