Android ConstraintLayout 两控件部分相叠兼容布局

ConstraintLayout  布局时有时候经常会有一些控件之间重叠的设计,直接设置距某一位置距离兼容性太差

我目前想到的是再重叠控件上放一个透明控件另一个根据他布局即可

示例:

LinearLayout叠在RecyclerView下方TextView是透明控件

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:id="@+id/container"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="@color/transparent"
  tools:context="com.kelvins.bilin.MainActivity">

      android:id="@+id/recyclerBanner"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:background="@color/transparent"
    app:layout_constraintDimensionRatio="H,10:4.4"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent">

  

      android:id="@+id/tv_top"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:background="@color/transparent"
    app:layout_constraintDimensionRatio="H,10:4.05"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

      android:id="@+id/linearLayout"
    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:alpha="0.99"
    android:background="@mipmap/icon_background"
    android:gravity="center"
    android:orientation="vertical"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/tv_top"
    app:layout_constraintVertical_bias="0.934">

你可能感兴趣的:(Android)