2017-10-03 13 views
0

スクロールビューを作成しようとしました。ただし、viewPagerはスクロールビュー内に表示されません。どの部分が間違っているのか分かりません。スクロールビューが相対レイアウトで機能しない

これは私のxmlファイルである

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView 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.qianonnphoon.tradeal.displaytrade.DisplayTradeActivity"> 

<RelativeLayout 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

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

    <android.support.design.widget.TabLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:tabBackground="@drawable/tab_selector" 
     app:tabGravity="center" 
     app:tabIndicatorHeight="0dp"> 
     </android.support.design.widget.TabLayout> 

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

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="23dp" 
    android:layout_below="@+id/view_pager" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" 
    android:id="@+id/tvOwnItemName"/> 
</RelativeLayout> 
</ScrollView> 

これはviewPagerが表示されていない出力 enter image description here

です。私は

答えて

0

をロードする前に、コードのこの部分を追加する追加

android:fillViewport="true" 

をスクロールビューに設定し、スクロールビューの高さを

に設定します210
android:layout_height="300dp" 

私の問題を解決します。私はアンドロイドを追加するとき

しかし、私は高さがwrap_content

0

これを試してスクロールビューを削除する場合viewPagerにのみ表示されます。

<ScrollView 
    android:id="@+id/scroll" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:scrollbars="vertical"> 
    android:fillViewport="true" > 


    <RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 
</RelativeLayout> 

</ScrollView> 
+0

として設定することができない理由を知らないそれはviewPagerを表示:fillViewportは=「true」を。ただし、スクロール可能ではありません。テキストビューを表示するためにスクロールできません – phoon

+0

テキストビューに何かを書きましたか? –

+0

はい、アンドロイドを追加する前にテキストを見ることができます:fillViewport = "true"。 – phoon

0

試しがあなたのviewPager

NestedScrollView scrollView = (NestedScrollView) findViewById 
(R.id.nest_scrollview); 
scrollView.setFillViewport (true); 
+0

viewPagerは表示されますが、スクロールできません – phoon

関連する問題