Android-ConstraintLayout

ConstraintLayout 负margin 最高效的方法

2021-08-04  本文已影响0人  炸山哥

看了很多文章说用Space实现,确实可以实现,但是还要多写一个控件,太麻烦了。
我们直接用translationY、translationX属性就可以了,如下:

    <ImageView
        app:layout_constraintTop_toTopOf="@id/ivShipBg"
        app:layout_constraintBottom_toBottomOf="@id/ivShipBg"
        app:layout_constraintStart_toEndOf="@id/ivShipBg"
        android:id="@+id/ivSeekbarBg"
        android:src="@drawable/mhyl_seekbar_bg"
        android:layout_width="@dimen/sw_238dp"
        android:scaleType="fitXY"
        android:translationX="-4dp"
        android:layout_height="@dimen/sw_20dp"/>
上一篇下一篇

猜你喜欢

热点阅读