android - 如何将属性 onClick 设置为 ScrollView?

标签 android onclick scrollview

我有以下布局

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/white" >

<LinearLayout
    android:id="@+id/answerMainFrame"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/white"
    android:isScrollContainer="true"
    android:onClick="toQuestion" >

    <ImageView
        android:id="@+id/answer_img"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:contentDescription="@string/question_img_cd" />

    <TextView
        android:id="@+id/answer"
        style="@style/Question" />
</LinearLayout>

有时 ScrollView太小了,不会填满整个屏幕,但我仍然想调用方法 toQuestion()单击屏幕上的任意位置。

我试过设置 android:layout_height="wrap_content"LinearLayoutandroid:onClick="toQuestion"ScrollView但结果相同。

最佳答案

您可以尝试让 LinearLayout 实现 onClick 属性,然后设置:

android:fillViewport="true"

ScrollView

关于android - 如何将属性 onClick 设置为 ScrollView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10651309/

相关文章:

Android Room SQLite_ERROR 没有这样的表

android - 应用程序 :stackFromEnd for RecyclerView is not working in xml?

javascript - 添加下一个按下的按钮值以输入 javascript

extjs - 如何将 onClick 方法添加到 TextField(ExtJS 框架)?

android - ImageView 不会填充父级

android - 多个viewpager的滚动效果

Android 应用内促销 : The code you entered is invalid

javascript - 点击 yt-video 时加载 js 函数?

android - 如何在布局中有许多子项的 Android 布局中添加垂直滚动条?

android - 在DialogFragment中,onCreate应该做什么?