首页 > 解决方案 > Android - 在 Imageview 上创建滚动按钮

问题描述

我有一个 ImageView 的活动,它比屏幕大,所以它位于 ScrollLayout 内。

我想在这个 imageView 上创建按钮,但是: - 如果我看不到整个图像,如何将按钮放在图像上?例如,我附加了一个绿色代表 imageView 而红色框代表按钮的图像。如果可滚动,我如何将所有按钮放在图像上?

在此处输入图像描述

标签: android

解决方案


您可以通过使用例如 aFrameLayout作为ScrollView. 所以你的 xml 看起来像这样:

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

        <Button .../>

        <Button .../>

        <Button .../>

    </FrameLayout>

</ScrollView>

推荐阅读