我有一個滾動視圖內的線性佈局。當爲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>
你可以發佈你的完整的XML? – Raghavendra
剛剛刪除了一些文本視圖和按鈕,仍然不能完成代碼 –
你可以改變線性佈局高度來匹配父母,並添加android:fillViewport =「true」來滾動視圖並嘗試。 – Raghavendra