我有一个android布局,其中包含scrollView许多元素.在scrollView我的底部有一个listView然后由适配器填充.
,我遇到的问题是,Android是不包括listView从scrollView作为scrollView已经具有滚动能够功能.我希望listView只要内容和主滚动视图是可滚动的.
我怎样才能实现这种行为?
这是我的主要布局:
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:fillViewport="true"
android:gravity="top" >
<LinearLayout
android:id="@+id/foodItemActvity_linearLayout_fragments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
然后我以编程方式将我的组件添加到具有id:的linearlayour foodItemActvity_linearLayout_fragments.下面是加载到该线性布局中的一个视图.这是给我卷轴问题的那个.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/fragment_dds_review_textView_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Reviews:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ListView
android:id="@+id/fragment_dds_review_listView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我的适配器然后填写此列表视图.
当我点击主滚动视图时,这是来自android层次结构查看器的图像:
如您所见,它排除了评论listView.
我应该能够向下滚动页面并查看8条评论,但它只向我展示了那些3,我可以滚动查看评论的小部分.我想要一个全局页面滚动
我正在尝试制作这样的布局:

问题是我不希望ListViews可滚动.我希望它们尽可能高,并使整个屏幕可滚动.如果我将ListView的高度设置为ListViews,则不起作用.使它工作的唯一方法是设置一个特定的高度 - 但我不知道ListView中有多少项.
我知道我不应该将ListView放在ScrollView中 - 但我不希望ListView可以滚动,只是为了显示所有项目.
也许还有更好的方法让它发挥作用?
我有一个列表视图,根据一些逻辑,我想临时禁用滚动.view.setOnScrollListener(NULL); 没有帮助我我想我需要写一些代码,有人可以给我一个文件或一些片段吗?
谢谢
我试图让某个布局工作时遇到一些困难:我想要列表.List不必是可滚动的,但应该完全显示.但是如果总内容高于屏幕,页面本身应该能够滚动(带有列表).
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linear_layout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#ff181818"
>
<Textview android:id="@+id/my_text" text="header contents goes here" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
<Textview android:id="@+id/headertext" text="header contents goes here" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
<ListView
android:id="@+id/my_list1"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
/>
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
它只使用屏幕的一小部分(每个列表约2行),而不是填充可用的高度,列表本身可以滚动.如何更改布局以始终显示整个列表,但屏幕是否为scrollalbe?
我应该想要一个不可滚动的ListView,并显示整个ListView.这是因为我的整个屏幕都是ScrollView,我用RelativeLayout调度小部件,所以我不需要ListView滚动.
我用代码设置我的ui,而不是用xml.
我用过listView.setScrollContainer(false),但它不起作用,我不明白为什么.
谢谢.
我有一个ListView内心ScrollView.我可以启用滚动ListView通过
listView.getParent().requestDisallowInterCeptTouchEvent(true);
Run Code Online (Sandbox Code Playgroud)
但问题是当我在listView中向上滚动并且它到达顶部时它应该滚动到父视图,即父滚动必须工作.我怎样才能做到这一点 ?任何建议请.