我有一个线性布局的列表视图。我想在ActionBar和我的ListView的第一个项目之间留出空间,比如YouTube应用:
为了得到这个结果,我尝试了填充和边距,以便linearlayout和listview,但是当用户滚动listview时,项目应该超出actionbar但是!!正如你在我的结果图像中看到的,项目开始从顶部边缘按空格消失!(空格是为ListView或LinearLayout设置的填充或边距)
有谁知道怎么处理这个问题吗?
谢谢

最佳答案

您只需将textview添加到listview上方的xml中。应该像下面这样:

<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>

07-24 09:47
查看更多