1

I'm building an application in which I have loaded the webpage on webview. I have one layout which contains edittext in that. I want to hide the layout when user is scrolling down in the webview and show it again when user scrolls to the top. I have tried using onTouch but it only takes the MotionEvent.ACTION_MOVE and all that. Here what my code looks like:

@Override
public boolean onTouch(View v, MotionEvent event) {
    if (v.getId() == R.id.web
            && event.getAction() == MotionEvent.ACTION_MOVE) {
        handler.sendEmptyMessageDelayed(CLICK_ON_URL, 2000);
    }
    return false;
}

@Override
public boolean handleMessage(Message msg) {
    if (msg.what == CLICK_ON_URL) {
        top.setVisibility(LinearLayout.GONE);
        return true;
    }
    return false;
}

As you can see here I'm using top.setVisibility(LinearLayout.GONE);, but this is not solving my problem, it completely hides my layout.

Any idea how to overcome this problem.

4

1 回答 1

2

您可以将布局和 webView 都包装在一个滚动视图中。这样当用户向下滚动时,父级将捕获滚动事件。以供参考,

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

<!-- Both your views goes here -->

</ScrollView>

希望有帮助。

于 2012-10-09T04:40:24.080 回答