问题描述
我想在Android中放的ListView
低于滚动型
。我试图把它们放置在 LineaLayout
像这样
I am trying to put a ListView
below a ScrollView
in android. I tried putting them inside a LineaLayout
like this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/frameLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ScrollView
android:id="@+id/marketDetailScrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
...
</ScrollView>
<ListView android:id="@android:id/list"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:background="#FFF"/>
</LinearLayout>
和的ListView
不会被显示。我也试图把它放在一个 RelaviteLayout
,仍然一无所获。我能以某种方式有一个的ListView
下滚动型
?
and the ListView
doesn't get shown. I also tried putting it inside a RelaviteLayout
and still nothing. Can I somehow have a ListView
under a ScrollView
?
我想补充一些东西。我不想拆我的屏幕,让我有一个半滚动型
,另一半用的ListView
。我希望用户向下滚动滚动型
这显然是大于屏幕尺寸,然后在的ListView
应该启动
Just to add something. I don't want to split my screen so that I have a half with a ScrollView
and another half with a ListView
. I want the user to scroll down the ScrollView
which apparently is bigger than the screen size and then the ListView
should start
推荐答案
我会建议你把滚动型内容HeaderView在ListView还是要明确有两个分开的滚动区域在屏幕上?
I would recommend you to put the ScrollView Content as HeaderView in the ListView or do you explicitly want to have two separated scrollable areas on screen?
实例把滚动视图的内容在列表视图头(一个单独的滚动区域):
public void onCreate(Bundle s){
setContentView(R.id.yourLayout);
ListView listView = (ListView) findViewById(R.id.listView);
// Set the adapter before the header, because older
// Android version may have problems if not
listView.setAdapter(new YourAdapter());
// Add the header
View header = inflater.inflate(
R.layout.you_layout_that_was_in_scrollview_before, null, false);
listView.addHeaderView(header);
}
活动的布局会是什么样子的:
The layout of the activity would look like that:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView android:id="@+id/listView"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="#FFF"/>
</LinearLayout>
如果你希望两个滚动的区域,你应该与布局重量:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:id="@+id/marketDetailScrollView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<!-- ScrollViewContent -->
</ScrollView>
<ListView android:id="@android:id/list"
android:layout_height="0dp"
android:layout_width="match_parent"
android:background="#FFF"
android:layout_weight="1"/>
</LinearLayout>
这篇关于下面滚动视图Android中的ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!