我有一個約束佈局,在那裏我有一個ImageView。我在我的XML下面放置了一個線性佈局,用於我希望我的應用程序滾動瀏覽的一些ImageButton。我研究並發現,我需要將我的線性佈局封裝在ScrollView中,但由於某種原因,它不會顯示我的內容的底部。它切斷了仿真器中視圖的底部。 我試圖在一個相對佈局中包裝ScrollView,這是在其中一個論壇中建議的,但是什麼也沒做。我也試着用android:fillViewport =「true」來設置ScrollView,但那也沒用。我將附上它看起來像的屏幕截圖,我將在下面粘貼XML。ScrollView不顯示完整內容?
screenshot of app with content not showing at bottom
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.autismacademyed.www.autismacademy.AutismAcademy">
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/logo" />
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/imageView2">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_marginTop="0dp"
android:orientation="vertical"
android:scrollIndicators="right|end"
android:scrollbars="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView2"
app:layout_constraintVertical_bias="0.0">
<ImageButton
android:id="@+id/imageButtonRed"
android:layout_width="104dp"
android:layout_height="124dp"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:background="@null"
android:onClick="imageButtonOnClick"
android:scaleType="centerCrop"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageButtonYellow"
app:srcCompat="@drawable/ic_action_red" />
<ImageButton
android:id="@+id/imageButtonBlue"
android:layout_width="125dp"
android:layout_height="110dp"
android:layout_marginTop="8dp"
android:background="@null"
android:scaleType="centerCrop"
app:layout_constraintTop_toBottomOf="@+id/imageButtonRed"
app:srcCompat="@drawable/ic_action_blue"
tools:layout_editor_absoluteX="0dp" />
<ImageButton
android:id="@+id/imageButtonYellow"
android:layout_width="109dp"
android:layout_height="125dp"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:background="@null"
android:onClick="imageButtonOnClick"
android:scaleType="centerCrop"
android:visibility="visible"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView2"
app:srcCompat="@mipmap/ic_yellowpuzzlepiece" />
<ImageButton
android:id="@+id/imageButtonGreen"
android:layout_width="109dp"
android:layout_height="125dp"
android:background="@null"
android:scaleType="centerCrop"
app:layout_constraintTop_toBottomOf="@+id/imageButtonYellow"
app:srcCompat="@drawable/ic_action_green" />
<ImageButton
android:id="@+id/imageButtonBrown"
android:layout_width="109dp"
android:layout_height="125dp"
android:background="@null"
android:scaleType="centerCrop"
app:layout_constraintTop_toBottomOf="@+id/imageButtonYellow"
app:srcCompat="@drawable/ic_action_green" />
</LinearLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
@Selvin我還是編程新手,所以你說的話對我來說沒有多大意義。如果你可以更具體地請做。 – ZachGiovanelli