讓我介紹你到我的活動:Android的滾動型不活動與抽屜佈局滾動
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/toolbar_actionbar"
layout="@layout/toolbar_default"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<FrameLayout
android:id="@+id/main_fragment_container"
android:layout_width="match_parent"
android:layout_below="@+id/toolbar_actionbar"
android:layout_height="match_parent"/>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar_actionbar">
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:clickable="true"
android:layout_height="match_parent"/>
<!-- android:layout_marginTop="?android:attr/actionBarSize"-->
<fragment
android:id="@+id/fragment_drawer"
android:name="com.package.name.navigationdrawer.NavigationDrawerFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
app:layout="@layout/fragment_navigation_drawer"/>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
的FrameLayout main_fragment_container是我加載取決於抽屜式導航欄選擇不同的片段,但是當我打開一個片段與ScrollView滾動不起作用,當加載片段時,我可以看到滾動條,表明此時只有一小部分在屏幕上,但它永遠不會滾動。我嘗試了一些提到在LinearLayout中包含ScrollView的建議,但沒有任何區別。
我懷疑導航抽屜「截獲」應該到達ScrollView的事件,但我失去了做什麼。這是片段:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical">
<ScrollView
android:id="@+id/fragment_who_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/header_pic_s"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="17sp"
android:text="TEEEEEST"
android:gravity="center"
android:padding="20dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="17sp"
android:text="TEEEEEST"
android:gravity="center"
android:padding="20dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="17sp"
android:text="TEEEEEST"
android:gravity="center"
android:padding="20dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="17sp"
android:text="TEEEEEST"
android:gravity="center"
android:padding="20dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="17sp"
android:text="TEEEEEST"
android:gravity="center"
android:padding="20dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="17sp"
android:text="TEEEEEST"
android:gravity="center"
android:padding="20dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="17sp"
android:text="TEEEEEST"
android:gravity="center"
android:padding="20dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="17sp"
android:text="TEEEEEST"
android:gravity="center"
android:padding="20dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="17sp"
android:text="TEEEEEST"
android:gravity="center"
android:padding="20dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="17sp"
android:text="TEEEEEST"
android:gravity="center"
android:padding="20dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="17sp"
android:text="TEEEEEST"
android:gravity="center"
android:padding="20dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="17sp"
android:text="TEEEEEST"
android:gravity="center"
android:padding="20dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="17sp"
android:text="TEEEEEST"
android:gravity="center"
android:padding="20dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="17sp"
android:text="TEEEEEST"
android:gravity="center"
android:padding="20dp"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
感謝您的時間。
UPDATE - 讓我添加一些額外的信息:
這裏的問題不是滾動型本身,而是事實,在我的活動佈局DrawerLayout是「上面」的滾動型防止任何觸摸事件到達ScrollView。如果我刪除DrawerLayout,ScrollView會滾動JUST FINE。
同樣,如果我在活動佈局中將DrawerLayout後面的ScrollView放置在ScrollView中,但當然DrawerLayout不能按預期工作,因爲它必須位於其他任何位置之上。
我希望適當解釋自己,通過測試我敢肯定的是什麼問題,但我不知道如何解決它,我的抽屜式導航的經驗是有限的,我不知道如何讓滾動事件傳遞給ScrollView,而不是讓DrawerLayout攔截它。佈局的
這並不解決您的問題,但你不需要你的滾動視圖的父linearlayout。您的滾動視圖應該充當主視圖。 –
謝謝,這是完全沒有必要的,我只是刪除它。我只嘗試過,因爲它在ScrollViews滾動問題時作爲答案給出。 – dbar
沒有問題:)爲什麼你的framelayout(容器)是可點擊的?這是你添加內容的地方嗎?嘗試刪除此標誌。 –