我在选项卡内的ListView的大小有问题。
我认为这很简单,但我找不到解决方案。
活动与默认相同,除了用ListView更改的TextView。
我使用带有三个项目(“P1”,“P2”,“P3”)的虚拟列表的ArrayAdapter。
所有尺寸都设置为“match_parent”或“WRAP_CONTENT”
我得到的是这样的:我只看到“P1”,而不是整个列表,用少许滚动条允许值之间滚动。
我想看到的是整个列表。
screenshot of my app
有人能帮助我吗?
Tab中的Android ListView只显示一行
主活动布局
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="it.danapps.mycommunity.ChooseTags">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay">
<Spinner
android:id="@+id/spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/container_choose_tags"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
片段
<RelativeLayout 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"
tools:context="it.danapps.mycommunity.ChooseTags$PlaceholderFragment">
<ListView
android:id="@+id/chooseTagListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
编辑
1.强制高度300dp我看到名单。但是,我怎样才能自动执行到Android,适应屏幕?
<RelativeLayout 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"
tools:context="it.danapps.mycommunity.ChooseTags$PlaceholderFragment">
<ListView
android:id="@+id/chooseTagListView"
android:layout_width="match_parent"
android:layout_height="300dp"
/>
尝试将ListView和NestedScrollView的android:layout_height更改为match_parent。 –
我试过了,但没有改变什么 – DanB