【发布时间】:2020-02-09 10:52:01
【问题描述】:
我在 android 应用中实现这种设计时遇到了一些麻烦。
我首先拥有的是一个 ConstraintLayout,里面有一个 ImageButton(包装他的内容)。没事。
但我还想要一个 HorizontalScreenView,它的宽度与 ImageButton 的宽度相同,并且在他内部有一个从水平方向开始的大型 ImageView HorizontalScreenView 的中心。
代码中情况的示例...
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/example"/>
<HorizontalScrollView
android:layout_width="¿HERE IS THE PROBLEM?"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
<!-- I WANT THIS IMAGE TO START AT THE CENTER OF PARENT (HorizontalScrollView) -->
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="false"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/example"/>
</HorizontalScrollView>
谢谢大家!
【问题讨论】:
标签: android layout constraints imagebutton