2014-11-24 108 views
0

我正在开发一个具有webview组件和列表视图组件的应用程序。我在我的webview上有一个透明的布局来捕获所有的用户事件。每当用户尝试滚动时,我都会在webview上执行javascript滚动功能。每次调用该函数,webview都会滚动并返回一个用于滚动列表视图的值。滚动我的列表视图我正在使用myListView.setSelectionFromTop(pos,y)。这里的问题是,如果我禁用滚动的列表视图,webview平滑滚动。但是,如果启用了listview,则webview不会平滑滚动。我的最终目标是同时滚动listview和webView。但它似乎滚动listview它阻止UI线程,从而使webview的滚动缓慢。ListView和WebView滚动

任何人都可以告诉我如何得到这个工作?

+0

你能共享XML? – 2014-11-25 05:29:58

回答

0

@MysticMagic这里是我的XML布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:widget="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="#FFFFFF"> 
<RelativeLayout 
    android:layout_width="40dp" 
    android:layout_height="match_parent" 
    android:layout_marginTop="26dp" 
    android:background="#FFFFFF" 
    android:gravity="center" 
    android:id="@+id/relLayout"> 
      <ListView 
       android:id="@+id/listview" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:dividerHeight="1dp" 
       android:divider="#D3D0D9" 
       android:layout_centerInParent="true" 
       android:background="#E2E2E2" 
       android:cacheColorHint="@android:color/transparent"    
       android:footerDividersEnabled="false" 
       android:gravity="center" 
       android:layout_gravity="center" 
       android:listSelector="@android:color/transparent" 
       android:visibility="visible" 
       android:fillViewport="true" /> 
</RelativeLayout> 
<RelativeLayout 
    android:layout_width="fill_parent" 
    android:id="@+id/webLayout" 
    android:background="#FFFFFF" 
    android:layout_height="fill_parent" 
    android:layout_toRightOf="@+id/relLayout"> 
       <WebView 
        android:id="@+id/webView" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:scrollbars="none"> 
       </WebView> 
       <com.example.view.CustomView 
        android:id="@+id/transparentView" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"   
        android:layout_alignParentTop="true" 
        android:layout_alignParentLeft="true"/>  
</RelativeLayout>