如果我试图添加ImageButton来布局,它似乎没有任何东西。任何人都可以帮助我?我尝试了一切,但它不起作用。 这里是代码: .XML:如何添加ImageButtons到ScrollView?
<ImageButton
android:id="@+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
android:src="@drawable/categories_action"
app:layout_constraintStart_toStartOf="@+id/scrollView2"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="MissingConstraints" />
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView2"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/cat_iv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:clickable="true"
android:src="@drawable/categories_first_background" />
</RelativeLayout>
</ScrollView>
背景是1080×1920图像
你想做什么?在scrollview上方放置按钮? –
我会建议将您的imageButton放在RelativeLayout中 – UserID0908
用问题 – Prem