我正在玩ConstraintLayout,我无法猜测如何使用只有一个ConstraintLayout来做这个简单的设计。ConstraintLayout可以实现这种设计吗?
- 每个TextView的居中,其图像。
- 每幅图像都用固定边距与以前的图像分开。
- 所有视图都像一个组一样被水平居中。
我已经实现了使用RelativeLayout的设计:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_height="match_parent">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="4dp">
<RelativeLayout
android:id="@+id/androidALayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/androidAIV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/ic_launcher"
android:layout_centerHorizontal="true"/>
<TextView
android:id="@+id/androidATV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Android A"
android:layout_below="@id/androidAIV"
android:layout_marginTop="4dp"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/androidBLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/androidALayout"
android:layout_marginLeft="32dp">
<ImageView
android:id="@+id/androidBIV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/ic_launcher"
android:layout_centerHorizontal="true"/>
<TextView
android:id="@+id/androidBTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Android B"
android:layout_below="@id/androidBIV"
android:layout_marginTop="4dp"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/androidCLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/androidBLayout"
android:layout_marginLeft="32dp">
<ImageView
android:id="@+id/androidCIV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/ic_launcher"
android:layout_centerHorizontal="true"/>
<TextView
android:id="@+id/androidCTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Android C"
android:layout_below="@id/androidCIV"
android:layout_marginTop="4dp"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/androidDLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/androidCLayout"
android:layout_marginLeft="32dp">
<ImageView
android:id="@+id/androidDIV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/ic_launcher"
android:layout_centerHorizontal="true"/>
<TextView
android:id="@+id/androidDTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Android D"
android:layout_below="@id/androidDIV"
android:layout_marginTop="4dp"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
这可能吗?