【发布时间】:2020-09-01 02:16:29
【问题描述】:
我将 ConstraintLayout、Guideline 和 ImageView 一起用于响应式视图。我在 ImageView 的顶部和底部获得了额外的间距。我尝试了android: adjustViewBounds 和android: scaleType,但没有成功如何清除?
这是它的样子:
代码如下:
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<androidx.constraintlayout.widget.Guideline
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/left_guideline"
app:layout_constraintGuide_percent=".20"
android:orientation="vertical"/>
<androidx.constraintlayout.widget.Guideline
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/right_guideline"
app:layout_constraintGuide_percent=".80"
android:orientation="vertical"/>
<ImageView
android:layout_width="0dp"
android:layout_height="0dp"
android:adjustViewBounds="true"
app:layout_constraintStart_toStartOf="@+id/left_guideline"
app:layout_constraintEnd_toEndOf="@+id/right_guideline"
app:layout_constraintDimensionRatio="w,1:1"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:src="@drawable/logoo" />
</androidx.constraintlayout.widget.ConstraintLayout>
【问题讨论】:
标签: android imageview android-constraintlayout