我已经尝试将这种布局构建为来自3个人的路径,用于表示包装的发送者和接收者:Layout I want
但是我无法达到。我的结果是...不好
这是我的布局代码:
<?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:id="@+id/rlMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#76e6e6e6"
android:padding="4dp"
android:divider="@drawable/contact_divider"
android:layout_margin="1dp">
<TextView
android:id="@+id/txtvRichiestaID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="false"
android:layout_centerVertical="false"
android:gravity="end|center_vertical"
android:visibility="gone"
android:text="CODICE RICHIESTA"
android:textSize="10sp" />
<!-- box blue -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum=""
android:background="@drawable/gradient_celeste"
>
<LinearLayout
android:id="@+id/box_mittente"
android:layout_width="0dp"
android:layout_weight="2"
android:layout_margin="5dp"
android:background="@drawable/box_arrotondato_mittente"
android:orientation="vertical"
android:layout_height="match_parent">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/imgMittente"
android:layout_width="@dimen/account_photo_dim"
android:layout_height="@dimen/account_photo_dim"
android:layout_centerVertical="true"
android:layout_margin="5dp"
android:background="@drawable/chatplaceholder" />
<TextView
android:id="@+id/nomeMittente"
android:layout_width="match_parent"
android:textSize="10sp"
android:ellipsize="middle"
android:textAlignment="center"
android:textColor="@android:color/white"
android:textStyle="bold"
android:layout_height="wrap_content"
android:text="Nome\n Mittente"/>
</LinearLayout>
<!-- boxer yellow --->
<LinearLayout
android:id="@+id/box_trasportatore"
android:layout_width="0dp"
android:layout_weight="2"
android:layout_margin="5dp"
android:background="@drawable/box_arrotondato_trasportatore"
android:layout_height="match_parent">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/imgTrasportatore"
android:layout_width="@dimen/account_photo_dim"
android:layout_height="@dimen/account_photo_dim"
android:layout_centerVertical="true"
android:layout_margin="5dp"
android:background="@drawable/chatplaceholder" />
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:gravity="center"
android:layout_height="match_parent">
<TextView
android:id="@+id/nomeTrasportatore"
android:layout_width="wrap_content"
android:textSize="10sp"
android:ellipsize="middle"
android:textAlignment="center"
android:textColor="@android:color/white"
android:textStyle="bold"
android:layout_height="wrap_content"
android:text="Nome\n Trasportatore"/>
</LinearLayout>
</LinearLayout>
<!-- boxer green --->
<LinearLayout
android:id="@+id/box_destinatario"
android:layout_width="0dp"
android:layout_weight="2"
android:layout_margin="5dp"
android:background="@drawable/box_arrotondato_destinatario"
android:layout_height="match_parent">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/imgDestinatario"
android:layout_width="@dimen/account_photo_dim"
android:layout_height="@dimen/account_photo_dim"
android:layout_centerVertical="true"
android:layout_margin="5dp"
android:background="@drawable/chatplaceholder" />
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:gravity="center"
android:layout_height="match_parent">
<TextView
android:id="@+id/nomeDestinatario"
android:layout_width="wrap_content"
android:textSize="10sp"
android:ellipsize="middle"
android:textAlignment="center"
android:textColor="@android:color/black"
android:textStyle="bold"
android:layout_height="wrap_content"
android:text="Nome\n Destinatario"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
有人可以帮我吗?这是用于代表运输商将包裹发送给其他人的。感谢您的帮助! :)
使用此代码
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:layout_width="100dp"
android:layout_height="100dp"
app:cardCornerRadius="50dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/ic_refer_friend"/>
</androidx.cardview.widget.CardView>
<View
android:layout_width="50dp"
android:layout_gravity="center_vertical"
android:layout_height="4dp"
android:background="@color/colorPrimary"/>
<androidx.cardview.widget.CardView
android:layout_width="100dp"
android:layout_height="100dp"
app:cardCornerRadius="50dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/ic_refer_friend"/>
</androidx.cardview.widget.CardView>
<View
android:layout_width="50dp"
android:layout_gravity="center_vertical"
android:layout_height="4dp"
android:background="@color/colorPrimary"/>
<androidx.cardview.widget.CardView
android:layout_width="100dp"
android:layout_height="100dp"
app:cardCornerRadius="50dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/ic_refer_friend"/>
</androidx.cardview.widget.CardView>
</LinearLayout>
Bellow是您的答案,我只用您的CircularImageView替换ImageView
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:background="@drawable/action_item_btn">
<ImageView
android:layout_width="100dp"
app:layout_constraintStart_toStartOf="parent"
android:id="@+id/mImgSender"
app:layout_constraintTop_toTopOf="parent"
android:src="@drawable/icon_user_cntclist"
android:layout_height="100dp" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="wrap_content"
android:id="@+id/mTVSenderName"
app:layout_constraintStart_toStartOf="@+id/mImgSender"
app:layout_constraintEnd_toEndOf="@+id/mImgSender"
android:text="Name Sen"
android:padding="5dp"
android:gravity="center"
app:layout_constraintTop_toBottomOf="@+id/mImgSender"
android:layout_height="wrap_content" />
<View
android:layout_width="0dp"
android:id="@+id/mViewDiv1"
app:layout_constraintStart_toEndOf="@+id/mImgSender"
app:layout_constraintEnd_toStartOf="@+id/mImgReceiver"
app:layout_constraintTop_toTopOf="@id/mImgSender"
app:layout_constraintBottom_toBottomOf="@id/mImgSender"
android:background="@color/colorAccent"
android:layout_height="15dp" />
<ImageView
android:layout_width="100dp"
android:id="@+id/mImgReceiver"
app:layout_constraintTop_toTopOf="@+id/mImgSender"
app:layout_constraintEnd_toEndOf="parent"
android:src="@drawable/icon_user_cntclist"
android:layout_height="100dp" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="wrap_content"
android:id="@+id/mTVReceiverName"
app:layout_constraintStart_toStartOf="@+id/mImgReceiver"
app:layout_constraintEnd_toEndOf="@+id/mImgReceiver"
android:text="Name Rec"
android:padding="5dp"
android:gravity="center"
app:layout_constraintTop_toBottomOf="@+id/mImgReceiver"
android:layout_height="wrap_content" />
<ImageView
android:layout_width="100dp"
android:id="@+id/mImgTrans"
app:layout_constraintTop_toTopOf="@+id/mImgSender"
android:src="@drawable/icon_user_cntclist"
app:layout_constraintStart_toEndOf="@id/mImgSender"
app:layout_constraintEnd_toStartOf="@+id/mImgReceiver"
android:layout_height="100dp" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="wrap_content"
android:id="@+id/mTVTransName"
app:layout_constraintStart_toStartOf="@+id/mImgTrans"
app:layout_constraintEnd_toEndOf="@+id/mImgTrans"
android:text="Name Trans"
android:padding="5dp"
android:gravity="center"
app:layout_constraintTop_toBottomOf="@+id/mImgTrans"
android:layout_height="wrap_content" />
</android.support.constraint.ConstraintLayout>