我想在屏幕頂部有一個「fixed_space」,屏幕底部應該有一個「scrollview」,應該在fixed_space下面。屏幕的其餘部分是一個容器「rest_space」。Android滾動查看內容大小應該是
不幸的是,如果內容太大/可滾動,我的滾動視圖的高度較低(fixed_space有100dp)。
我試圖用ConstraintLayout和RelativeLayout來實現,但是我得到了相同的結果。 任何想法爲什麼scrollview有100dp較短的高度,因爲它應該是?
編輯:ScrollView應該儘可能多的空間,她需要。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:id="@+id/fixed_space"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@android:color/holo_red_dark" />
<View
android:id="@+id/rest_space"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@android:color/black" />
<ScrollView
android:id="@+id/scrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/holo_green_dark"
android:fillViewport="true">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="START OF SCROLLVIEW \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nMIDDLE OF SCROLLVIEW \n\n\n\n\n\n\n\n\n\n\n\nEND OF SCROLLVIEW" />
</ScrollView>
</LinearLayout>
你有沒有試圖消除「rest_space」認爲,應該是問題 –
告訴我fixed_space,rest_space的比例和滾動型你想要什麼?。 –
@PierGiorgioMisley ScrollView應該只佔用她需要的太多空間。如果我刪除rest_space,滾動視圖將在fixed_space和底部屏幕之間佔用整個空間。 – prosto