我有一個線性佈局和一個viewpager,它包含一個列表視圖。滾動時,我希望線性佈局(餐廳頁面和圖像)上升。爲此,我嘗試使用scrollView,但它不起作用。我該怎麼辦? ScrollView不工作
這是XML -
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:fillViewport="true"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:id="@+id/ResView"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/header_restaurant_page" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginTop="-40dp"
android:background="#ffffff">
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:padding="20dp"
android:background="@android:color/black">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:textAlignment="center"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Pre Order"
android:id="@+id/textView8"
android:gravity="center"
android:textColor="#ffffff" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:textAlignment="center"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Pay Online"
android:id="@+id/textView9"
android:gravity="center"
android:textColor="#ffffff" />
</LinearLayout>
<com.astuetz.PagerSlidingTabStrip
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="30dp"
android:textSize="15sp"
app:pstsIndicatorHeight="3dp"
app:pstsShouldExpand="true"
app:pstsIndicatorColor="@color/white"
app:typeface="robotoRegular"
android:textColor="#fff"
android:background="@android:color/black"/>
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent" android:layout_height="wrap_content"
tools:context="com.csform.android.uiapptemplate.restaurant"
android:background="#fff">
</android.support.v4.view.ViewPager>
</LinearLayout>
</LinearLayout>
</ScrollView>
包括標籤是針對餐館信息的標題。 如果可能,我想在頁面滾動時將PagerSlidingTabStrip(優惠,菜單,關於,評論)貼到最前面。
可能會嘗試使用高度包裝內容滾動視圖 – justDroid
在LinearLayout之前添加此行 '。 –