看了很多文章說(shuō)用Space實(shí)現(xiàn),確實(shí)可以實(shí)現(xiàn),但是還要多寫一個(gè)控件,太麻煩了。
我們直接用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"/>