ConstraintLayout实现负距离效果

已选中 倾斜切负距离;(实际 是 通过 左右距离 固定宽度 实现的)

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:simple="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:layout_margin="@dimen/dp_10"
    android:background="@color/transparent">

    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/shape_coupon_up"
        android:orientation="horizontal"
        simple:layout_constraintBottom_toBottomOf="parent"
        simple:layout_constraintEnd_toEndOf="parent"
        simple:layout_constraintStart_toStartOf="parent"
        simple:layout_constraintTop_toTopOf="parent">

        <android.support.constraint.ConstraintLayout
            android:id="@+id/left"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:background="@drawable/shape_coupon_left"
            simple:layout_constraintEnd_toStartOf="@+id/right"
            simple:layout_constraintHorizontal_weight="2"
            simple:layout_constraintStart_toStartOf="parent"
            simple:layout_constraintTop_toTopOf="parent">


            <TextView
                android:id="@+id/tv_coupon_type"
                android:layout_width="80dp"
                android:layout_height="25dp"
                android:background="@drawable/shape_coupon_type"
                android:gravity="center"
                android:text="现金券"
                android:textColor="@color/white"
                android:textSize="@dimen/sp_12"
                simple:layout_constraintStart_toStartOf="parent"
                simple:layout_constraintTop_toTopOf="parent" />

            <TextView
                android:id="@+id/tv_content"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginStart="10dp"
                android:layout_marginTop="6dp"
                android:ellipsize="end"
                android:maxLines="1"
                android:text="任意订单减0.5元"
                android:textColor="@color/gray_order"
                simple:layout_constraintEnd_toEndOf="parent"
                simple:layout_constraintStart_toStartOf="parent"
                simple:layout_constraintTop_toBottomOf="@+id/tv_coupon_type" />

            <TextView
                android:id="@+id/tv_rules"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="10dp"
                android:layout_marginTop="6dp"
                android:text="通用打印:文档、图片、照片、身份证"
                android:textColor="@color/gray_order"
                android:textSize="@dimen/font_10"
                simple:layout_constraintStart_toStartOf="parent"
                simple:layout_constraintTop_toBottomOf="@+id/tv_content" />

            <TextView
                android:id="@+id/tv_time"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="10dp"
                android:layout_marginTop="4dp"
                android:text="有效期:2019-10-11至2019-11-11"
                android:textColor="@color/gray_order"
                android:textSize="@dimen/font_10"
                simple:layout_constraintStart_toStartOf="parent"
                simple:layout_constraintTop_toBottomOf="@+id/tv_rules" />

        </android.support.constraint.ConstraintLayout>

        <android.support.constraint.ConstraintLayout
            android:id="@+id/right"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:background="@drawable/shape_coupon_right"
            simple:layout_constraintEnd_toEndOf="parent"
            simple:layout_constraintHorizontal_weight="1"
            simple:layout_constraintStart_toEndOf="@+id/left"
            simple:layout_constraintTop_toTopOf="parent">

            <TextView
                android:id="@+id/tv_money"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="15dp"
                android:text="0.5"
                android:textColor="@color/white"
                android:textSize="@dimen/font_30"
                simple:layout_constraintEnd_toEndOf="parent"
                simple:layout_constraintStart_toStartOf="parent"
                simple:layout_constraintTop_toTopOf="parent" />

            <TextView
                android:id="@+id/tv_money_symbol"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/money_simple"
                android:textColor="@color/white"
                simple:layout_constraintBaseline_toBaselineOf="@+id/tv_money"
                simple:layout_constraintStart_toEndOf="@+id/tv_money" />

            <TextView
                android:id="@+id/tv_platform"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginStart="10dp"
                android:layout_marginTop="4dp"
                android:layout_marginEnd="10dp"
                android:ellipsize="end"
                android:maxLines="2"
                android:text="所有校区/所有平台通用"
                android:textColor="@color/white"
                android:textSize="@dimen/font_10"
                simple:layout_constraintEnd_toEndOf="parent"
                simple:layout_constraintStart_toStartOf="parent"
                simple:layout_constraintTop_toBottomOf="@+id/tv_money" />

            <TextView
                android:id="@+id/tv_select"
                android:layout_width="70dp"
                android:layout_height="20dp"
                android:layout_marginStart="50dp"
                android:layout_marginTop="8dp"
                android:background="@color/white"
                android:gravity="center"
                android:rotation="45"
                android:text="已选中"
                android:textColor="@color/app_yellow"
                android:textSize="@dimen/font_11"
                android:visibility="visible"
                simple:layout_constraintEnd_toEndOf="parent"
                simple:layout_constraintStart_toStartOf="@+id/tv_money"
                simple:layout_constraintTop_toTopOf="parent" />
        </android.support.constraint.ConstraintLayout>
    </android.support.constraint.ConstraintLayout>

</android.support.constraint.ConstraintLayout>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值