我有这个吉他指板图像,我想在上面放置点,但 android studio 的设计师不允许我滚动它来放置它们。这是一张大图,因此无法一次显示整个内容,需要在设计器中滚动并使用 java 以编程方式滚动(我已经在使用后者)。
这是我的简单 xml 代码
<?xml version="1.0" encoding="utf-8"?>
<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">
<ImageView
android:id="@+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:rotation="90"
android:scaleType="centerCrop"
android:src="@drawable/fretboard"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
</androidx.constraintlayout.widget.ConstraintLayout>
这是在任何人想要尝试复制时使用的图像。我在 Android Studio 4.0.1 上,模拟器运行的是 Android 9.0 Wear OS。
如您所见,它在 xml 中翻转了 90 度,这使得它更难一些。我不得不居中裁剪它,因为它不会让我在不离开屏幕的情况下使用高度和宽度参数来增加它的大小。图像可以使用 java OnTouchListener 很好地滚动,尽管有点草率。对此,我们深表感谢任何帮助。