android - ActionBar 和 ListView 行之间的空间

标签 android android-layout listview android-listview android-ui

我在 LinearLayout 中有一个 ListView。我想在操作栏和 ListView 的第一项之间留出空间,例如 YouTube 应用程序: enter image description here

为了得到这个结果,我尝试了填充和边距以便 LinearLayout 和 ListView,但是当用户滚动 ListView 时,项目应该超出 Actionbar 但是!正如您在我的结果图像中看到的那样,项目开始从顶部边缘开始消失! (空格是我为 ListView 或线性布局设置的填充或边距)

有没有人知道如何处理这个问题?

谢谢

最佳答案

你需要做的就是在listview上面的xml中添加一个textview。应如下所示:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.90" />

    <ListView
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="422dp" />

</LinearLayout>

关于android - ActionBar 和 ListView 行之间的空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24402727/

相关文章:

android - System.out.println() 的等效方法而不是 Log

android - 列表 Activity 中的上下文菜单

android - 为什么我无法登录 Android Studio for firebase?

c# - Asp.NET ListView数据控件动态Databind

delphi - 避免 TListView 项目剪切并替换为省略号的简单方法

android - 如何在 Android 2.3.3 的 ListView 中突出显示选定的行。 (HoloeveryWhere + ABS)

android - 如何获得具有 2 个等宽列的 TableLayout

android - 如何对具有不同内容的三个选项卡使用相同的 fragment ?

android - 包装内容不起作用

android - 将 TextView 在 ImageView 内水平居中,Imageview 旁边还有另一个 View