我在FrameLayout中有一个ScrollView和一个
ImageView.
ImageView位于滚动视图的后面
我的ScrollView有一个透明空间(LinearLayout s_layout_transparent,高度为925px).
所以我的ImageView可以通过这个透明空间看到,但无法点击.
我试图添加一些值(android:clickable =“false”android:focusable =“android:focusableInTouchMode =”false“)滚动视图以防止它拦截ImageView的点击事件,但这根本不起作用.
这是我的布局:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:gravity="top|center_horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingRight="10dp"
>
<ImageView
android:visibility="visible"
android:id="@+id/s_imgv_splash"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/temp_detail_screen_splash"
android:adjustViewBounds="true"
android:scaleType="fitXY"/>
</LinearLayout>
<com.dreamBox.android.saven.Views.ScrollView
android:id="@+id/s_scrollview_event_detail"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none"
android:visibility="visible"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="false"
android:focusableInTouchMode="false"
android:focusable="false">
<LinearLayout
android:id="@+id/s_layout_transparent"
android:layout_gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="925px"
android:orientation="horizontal"
android:background="@color/trasparent"
android:clickable="false"
android:focusableInTouchMode="false"
android:focusable="false">
</LinearLayout>
<LinearLayout...>
<LinearLayout...>
</LinearLayout>
</com.dreamBox.android.saven.Views.ScrollView>
</FrameLayout>
解决方法
如果你可以用空视图填充透明部分(让我们称之为dummyView),你可以做类似……
dummyView.setonTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view,MotionEvent event) {
// pass on the touch event to the ImageView
s_imgv_splash.dispatchTouchEvent(event);
// returning true because we handled the event
return true;
}
});