【发布时间】:2020-03-08 21:54:47
【问题描述】:
我看不到列表视图的第一行。我假设屏幕页面的标题与列表视图重叠。
我的片段文件如下:
<?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="wrap_content" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
任何建议都会很有帮助。
编辑:我在下面包含我的活动文件。
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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/coordinator_layout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".views.activities.ColorActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<fragment
android:id="@+id/color_fragment"
android:name="com.microsoft.skype.teams.views.fragments.ColorFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.constraint.ConstraintLayout>
作为 hack,我目前正在添加额外的一行数据。添加额外的数据行显然是我希望避免的。
【问题讨论】:
-
您是否在列表视图上方添加了工具栏?
-
如果这确实是
Fragment的布局,那么问题很可能主要在于Activity布局。 -
在您的活动布局中,将
FrameLayout放在您的工具栏下方。 -
这是由于工具栏的原因,在下面查看我的答案,看看你是否能得到你想要的。
-
该布局中的内部元素表明您的意思是使用
<CoordinatorLayout>作为根,而不是<ConstraintLayout>。如果您更改为<CoordinatorLayout>,则<fragment>上的layout_behavior将使其自动布置在<AppBarLayout>下方。
标签: android listview user-interface