如果你希望所有的意见,得到滚动单滚轮里面,有一个非常有用的库 - commonsguy/cwac-merge
有你需要Ø满足使用单个条件代码如下。请记住,针对您的问题的这种方法可能会有所不同,但最终结果正是您需要的。
条件:
- 这个库只能与ListView的使用。
这就是所有,让我们开始。
让你的活动布局这样的:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#FFFFFF">
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
</RelativeLayout>
创建一个新的布局XML。让它被命名为viewWebView.xml
并粘贴 此代码:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="120dp"
android:layout_alignParentBottom="true"
android:background="#767676">
</WebView>
</RelativeLayout>
创建一个新的布局XML。让它被命名为viewTextView.xml
并粘贴 此代码:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello There"
android:textColor="#FFFFFF">
</TextView>
</RelativeLayout>
所以,现在我们有一个Java文件的工作。打开你的* Activity.java文件 和库的用法如下。
ListView list = (ListView) findViewById(R.id.list);
MergeAdapter mg = new MergeAdapter();
/**
* Prgram your webview
*/
View web = getLayoutInflater().inflate(R.layout.viewWebView, null);
WebView web = (WebView) web.findViewById(R.id.webView);
//TODO: Code your webview!!
mg.addView(web);
mg.addView(getLayoutInflater().inflate(R.layout.viewTextView, null));
list.setAdapter(mg);
观光Rememeber:MergeAdpater
下
- 意见将在您添加视图的方式加入。换句话说,您的顺序是
mg.addView(View)
将是ListView中项目出现的顺序。
干杯!如果您在执行任何操作时遇到任何问题,或者将库添加到Gradle中,请让我知道!
祝你好运!
要帮助你的人,这个问题需要清除。你的问题不清楚。那么,为什么你想要滚动根视图?或者你想从滚动rootView中获得什么?因为视图无论如何都是可滚动的。 – Want2bExpert
将Scrollable视图放入另一个Scrollable视图是一种**糟糕的做法。 –
因为我有其他意见,并且webview不够高 – LichFaker