如果我試圖添加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