2016-03-22 1 views
0

私はスクロールビュー内に線形レイアウトを持っています。 ViewPagerに `android:layout_height =" wrap_content "と指定すると、リテラル値が設定されるまで消えます。どうしてか分かりません? 私のXMLコード:ViewPagerは、ScrollView内にラップすると消滅します

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

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

    ..... 

    <ImageView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:scaleType="centerCrop" 
     android:src="@drawable/moto" /> 

    <android.support.v4.view.ViewPager 
     android:id="@+id/viewshop_pager" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 

     <android.support.v4.view.PagerTabStrip 
      android:id="@+id/viewshop_pagerStrip" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="top" 
      android:background="@color/blueStrip" 
      android:paddingBottom="5dp" 
      android:paddingTop="5dp" /> 

    </android.support.v4.view.ViewPager> 

</LinearLayout> 

+0

ur complete xml? – Raghavendra

+0

いくつかのテキストビューとボタンを削除しても、完全なコードはまだ動作しません –

+0

親と一致するように直線レイアウトの高さを変更し、android:fillViewport = "true"をスクロールビューに追加して試すことができます。 – Raghavendra

答えて

0

スクロール後に崩壊のためにそれ

<android.support.design.widget.CollapsingToolbarLayout 

内部

android.support.design.widget.CoordinatorLayout 

その後、

<android.support.design.widget.AppBarLayout 

を使用することを決めたスタックの友人の助けと私のviewPagerを追加する GitHubでこのコードをお寄せいただきありがとうございます。 CollapsingToolbarLayout with TabLayout

0

はこれを試してみてください。私に知らせてください。ウェブの周りに検索すると後

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content"> 

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

    ..... 

    <ImageView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:scaleType="centerCrop" 
     android:src="@drawable/moto" /> 

    <android.support.v4.view.ViewPager 
     android:id="@+id/viewshop_pager" 
     android:layout_width=" match_parent" 
     android:layout_height="wrap_content"> 

     <android.support.v4.view.PagerTabStrip 
      android:id="@+id/viewshop_pagerStrip" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="top" 
      android:background="@color/blueStrip" 
      android:paddingBottom="5dp" 
      android:paddingTop="5dp" /> 

    </android.support.v4.view.ViewPager> 

</LinearLayout> 
+0

に感謝のような何かをスクロールする必要があります。しかし、@ Raghavendraの答えは私の問題を解決しました。 android:fillViewport = "true"をスクロールビューに追加する必要があります –

+0

が機能しません。 android:fillViewport = "true"を追加するとビューページが表示されますが、スクロールが機能しません。 –

+0

nestedscrollviewを使用しようとしています。それは鉱山で動作します – Raizal

関連する問題