[英]I need android layout configurations
您可以使用ContraintLayout以獲得更大的靈活性。
使用app:layout_constraintHeight_percent
屬性以百分比表示高度
您可以使用以下代碼在兩個布局之間對齊Image
。
app:layout_constraintBottom_toTopOf="@id/layout2"
app:layout_constraintTop_toBottomOf="@id/layout1"
這是實現您提到的布局的完整代碼。
<LinearLayout
android:id="@+id/layout1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="@id/layout2"
app:layout_constraintHeight_percent="0.7" // 70% of height
app:layout_constraintTop_toTopOf="parent">
</LinearLayout>
<LinearLayout
android:id="@+id/layout2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="center"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHeight_percent="0.3" // 30% of height
app:layout_constraintTop_toBottomOf="@id/layout1">
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="center" />
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="center"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp" />
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="center" />
</LinearLayout>
<ImageView
android:id="@+id/image"
android:layout_width="100dp"
android:layout_height="100dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
// To align image between layout1 and layout2
app:layout_constraintBottom_toTopOf="@id/layout2"
app:layout_constraintTop_toBottomOf="@id/layout1" />
</android.support.constraint.ConstraintLayout>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.