gpt4 book ai didi

android - Listview 与 ToolBar 重叠

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:23:24 27 4
gpt4 key购买 nike

我正在使用 android 设计支持库。

ListView 第一行与 Toolbar 小部件重叠。

在我的 MainActivity 中,我添加了协调布局,并在第一个 TAB fragment 中添加了 ListView 布局。

但是 ListView 的第一行被剪切了,因为如果 Toolbar 选项卡。

如何解决这个问题?

主.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<RelativeLayout
android:id="@+id/coordi"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

<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/ThemeOverlay.AppCompat.Light" />

<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabIndicatorColor="#FFEB3B"
app:tabIndicatorHeight="6dp"
app:tabSelectedTextColor="@android:color/white"
app:tabTextColor="@android:color/white" />

</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="16dp"
android:src="@drawable/plus" />

</android.support.design.widget.CoordinatorLayout>

</RelativeLayout>

<android.support.design.widget.NavigationView
android:id="@+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/layout_drawer_header" />

</android.support.v4.widget.DrawerLayout>


list_view.xml:
-------------
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="match_parent"></ListView>

最佳答案

我遇到了类似的问题,在遵循最佳答案后,我重写了我的代码以使用 RecyclerView 并遇到了同样的问题。然后我将此行为添加到我的内容布局中并且它起作用了

app:layout_behavior="@string/appbar_scrolling_view_behavior"

关于android - Listview 与 ToolBar 重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31768854/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com