我有4个视图,我需要将它们分为2组,然后使它们覆盖整个区域。
我尝试使用
我希望得到以下效果:
我已经做到了以下效果:
下面是相应的代码:
我尝试使用
Group
和chainStyle
,但没有一种方法能够100%满足要求。我希望得到以下效果:
![enter image description here](https://istack.dev59.com/tzQW1.webp)
![enter image description here](https://istack.dev59.com/JnXOn.webp)
<?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="wrap_content"
android:background="@color/colorBtnPink"
android:paddingTop="@dimen/_10sdp"
android:padding="@dimen/_10sdp">
<ImageView
android:id="@+id/ivFb"
android:layout_width="@dimen/_40sdp"
android:layout_height="@dimen/_40sdp"
android:background="@color/colorBgBtnFbDark"
android:clickable="false"
android:padding="@dimen/_10sdp"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_facebook"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/tvFacebook"
style="@style/tvSmallPopMedium"
android:layout_width="0dp"
android:layout_height="@dimen/_40sdp"
android:background="@color/colorBgBtnFacebook"
android:clickable="false"
android:gravity="center"
android:paddingBottom="@dimen/padding_regular"
android:paddingTop="@dimen/padding_regular"
android:text="@string/action_facebook"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintLeft_toRightOf="@+id/ivFb"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/ivTwitter"
android:layout_width="@dimen/_40sdp"
android:layout_height="@dimen/_40sdp"
android:background="@color/colorBgBtnTwDark"
android:clickable="false"
android:padding="@dimen/_10sdp"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintLeft_toRightOf="@+id/tvFacebook"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_twitter"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/tvTwitter"
style="@style/tvSmallPopMedium"
android:layout_width="0dp"
android:layout_height="@dimen/_40sdp"
android:background="@color/colorBgBtnTwitter"
android:clickable="false"
android:gravity="center"
android:paddingBottom="@dimen/padding_regular"
android:paddingTop="@dimen/padding_regular"
android:text="@string/action_twitter"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintLeft_toRightOf="@+id/ivTwitter"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
ConstraintLayout
来实现。 - buzzingsilentlyConstraintLayout
提供了app:layout_constraintWidth_percent
属性,但我无法在 4 个视图和app:layout_constraintHorizontal_chainStyle
中管理它。 - buzzingsilently0dp
? - buzzingsilently