Java ListView无法在Android中自动增长
在填充ListView时,我遇到了两个问题。 1.我看不到第一个元素。 2.我只有在硬编码高度时才能看到我的列表。我如何避免这种情况Java ListView无法在Android中自动增长,java,android-layout,listview,Java,Android Layout,Listview,在填充ListView时,我遇到了两个问题。 1.我看不到第一个元素。 2.我只有在硬编码高度时才能看到我的列表。我如何避免这种情况 <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="?attr/layout_background_color">
<LinearLayout
android:id="@+id/colors_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="visible">
<ListView
android:id="@+id/colors_list"
android:layout_width="match_parent"
android:layout_height="3500dp" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
谢谢你给我的任何帮助。谢谢 发生这种情况是因为您将
列表视图
放在嵌套滚动视图
中
ListView
可以是任何布局
,但是如果你想把它放在嵌套滚动视图
中,你必须做些什么。生活中没有什么是免费的
解决方案:
以编程方式计算高度
是解决您的问题的链接
或
使用
RecyclerView
而不是ListView
,您将不需要进行上述黑客操作。非常感谢您提供的提示!知道我为什么看不到列表中的第一个元素吗?我看到了除第一位以外的所有其他成员。