2016-07-27 31 views
-1

我創建了一個滾動視圖,它應該允許我滾動線性佈局(這是滾動視圖的子項)內的所有內容。Android的滾動查看片段作物內容

代碼如下所示:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="pl.oakfusion.delegator.DomesticDelegationSecondFragment"> 

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

    .... 

    <Button 
     android:id="@+id/button" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginRight="25dp" 
     android:layout_marginTop="25dp" 
     android:background="@color/textDarkest" 
     android:text="Save" 
     android:textColor="@color/textColor" 
     android:layout_gravity="right" /> 
</LinearLayout> 

預覽看起來是這樣的:

Preview

但在我的應用我有這樣的:

App portrait

我不能向下滾動,這是我所能看到的。

如果我允許旋轉我橫看:

App horizontal

現在讓我來滾動而是完全切割按鈕。 (在圖片底部的視圖)我可以快速拉下來,我可以看到按鈕在那裏,但它再次上升(這個Android的東西,當你可以稍微拉一點,但它滾動回來)

我怎樣才能解決這個問題?

託管活動:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 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:id="@+id/main_content" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true" 
tools:context="pl.oakfusion.delegator.DomesticDelegationActivity"> 

<android.support.design.widget.AppBarLayout 
    android:id="@+id/appbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:paddingTop="@dimen/appbar_padding_top" 
    android:theme="@style/AppTheme.AppBarOverlay"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     app:layout_scrollFlags="scroll|enterAlways" 
     app:popupTheme="@style/AppTheme.PopupOverlay"> 

    </android.support.v7.widget.Toolbar> 

</android.support.design.widget.AppBarLayout> 

<android.support.v4.view.ViewPager 
    android:id="@+id/container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

+0

增加這了滾動如何你的活動佈局看起來像(XML)?你使用一些CoordinatorLayout像這裏http://stackoverflow.com/questions/31709100/how-to-use-coordinator-layout-with-fragment-as-scrolling-view? – Tom

+0

請分享您的完整xml,以及託管佈局(如果有)以糾正問題。 – Neo

+0

對,更新帖子 – user3212350

回答

0

嘗試在你的XML佈局

android:fillViewport="true" 
+0

這不起作用 – user3212350

+0

如果你將它設置爲false?對於很多人來說,這應該可以解決問題 – ddb

+0

兩種方式都行不通 – user3212350