我正在為我和我在 android studio 中的朋友制作一個音箱。我有一個簡單的滾動視圖,我填充了多個約束布局,每個約束布局包含 2 個影像視圖,每個影像視圖下都有一行文本。
問題是,當我運行應用程式時,我只看到前 2 個布局,我不知道發生了什么,這可能不是好方法。
這里最好的解決方案是什么?這是xml代碼:
<androidx.constraintlayout.widget.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:id="@ id/linearLayout"
android:layout_width="match_parent"
android:layout_height="800dp"
android:background="#353535"
tools:context=".MainActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:id="@ id/buttonStopAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/red_perso"
android:text="Stop tout"
android:textColor="#000000" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@ id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="200dp">
<ImageView
android:id="@ id/idTheoGonfle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/theosouffle" />
<ImageView
android:id="@ id/idChuteCJ"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/cjchute" />
<TextView
android:id="@ id/textTheoGonfle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="150dp"
android:background="#FFEB3B"
android:fontFamily="sans-serif-black"
android:gravity="center"
android:text="Théo gonfle"
android:textAllCaps="false"
android:textColor="#000000"
android:textSize="16sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@ id/idTheoGonfle" />
<TextView
android:id="@ id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="150dp"
android:background="#FFEB3B"
android:fontFamily="sans-serif-black"
android:text="TextView"
android:textAlignment="center"
android:textColor="#000000"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@ id/idChuteCJ" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@ id/constraintLayout4"
android:layout_width="match_parent"
android:layout_height="200dp">
<ImageView
android:id="@ id/imageView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_launcher_foreground" />
<ImageView
android:id="@ id/imageView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_launcher_foreground" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@ id/constraintLayout3"
android:layout_width="match_parent"
android:layout_height="200dp">
<ImageView
android:id="@ id/imageView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@tools:sample/avatars" />
<ImageView
android:id="@ id/imageView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@tools:sample/avatars" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@ id/constraintLayout2"
android:layout_width="match_parent"
android:layout_height="200dp">
<ImageView
android:id="@ id/imageView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@tools:sample/avatars" />
<ImageView
android:id="@ id/imageView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@tools:sample/avatars" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>```
uj5u.com熱心網友回復:
看起來你是初學者。
<androidx.constraintlayout.widget.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:id="@ id/linearLayout"
android:layout_width="match_parent"
android:layout_height="800dp"
android:background="#353535"
tools:context=".MainActivity">
看起來像你的問題 android:layout_height="800dp" 你設定了固定高度。將其更改為 match_parent。<androidx.constraintlayout.widget.ConstraintLayout。并將根布局更改為 FrameLayout 或將其洗掉。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/411576.html
標籤:
上一篇:Android矢量圓線寬
