<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainArithmetic"
android:background="@drawable/sizebj"> //背景图
<ImageView
android:id="@+id/imageButton1"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/sizesp_000" //适配背景的小图片
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHeight_percent="0.075"
app:layout_constraintHorizontal_bias="0.31"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.071"
app:layout_constraintWidth_percent="0.2">
</ImageView>
</androidx.constraintlayout.widget.ConstraintLayout>
背景图: 960 * 1280?
适配背景的小图片: 192*96
把这个设成 0dp?
android:layout_width="0dp" android:layout_height="0dp"?
小图片宽和高:
app:layout_constraintHeight_percent="0.075"? ? 96/1280=0.075
app:layout_constraintWidth_percent="0.2"? ? ? ?192/960 = 0.2
小图片的位置:
?要放在原图(960*1280)的 238 *84 位置
??/* 960*1280??(背景图) 美工提供的比例 开始坐标和长宽 利用bias设置权重0.31(约等于)??238/(960-192)。
app:layout_constraintHorizontal_bias="0.31"??
高度:?
??/* 960*1280??(背景图) 美工提供的比例 开始坐标和长宽 利用bias设置权重0.071?(约等于)??? 84/(1280-96)。
app:layout_constraintVertical_bias="0.071"
|