【发布时间】:2020-03-04 18:43:45
【问题描述】:
我想在我的主页中有几个 ImageButtons,所以它应该在一个 ScrollView 中以允许用户滚动浏览所有这些按钮。但是,它没有按预期工作。
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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"
tools:context=".Activities.HomeFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:id="@+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="216dp"
android:background="@drawable/lunchimg" />
<ImageButton
android:id="@+id/lunch"
android:layout_width="wrap_content"
android:layout_height="216dp"
android:background="@drawable/lunchcate" />
<ImageButton
android:id="@+id/dinner"
android:layout_width="wrap_content"
android:layout_height="216dp"
android:background="@drawable/healthyfood" />
</LinearLayout>
</ScrollView>
当我运行代码时,只出现第一个按钮,其他按钮由于某种原因在它后面。
【问题讨论】:
-
尝试在线性布局中添加 android:orientation="vertical"。
标签: android scrollview