Android ListView with Scrollbar aligned with header

时间秒杀一切 提交于 2019-12-11 14:28:36

问题


I have the following code for my listview with a header: The LinearLayout contains all my header and the rest is my listview:

<LinearLayout android:id="@+id/cabecalho_tabela_listar_salas"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="35dp"
android:orientation="horizontal"
android:background="@drawable/red_header"
android:layout_below="@+id/botaoCriarNovaSala" >
    <TextView
            android:id="@+id/label_titulo_username"
            android:layout_width="0px"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_gravity="center"
            android:text="@string/email"
            android:textColor="#FFFFFF" />

        <TextView
            android:id="@+id/label_titulo_do_jogador"
            android:layout_width="0px"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_gravity="center"
            android:text="@string/dan"
            android:textColor="#FFFFFF" />

        <TextView
            android:id="@+id/label_categorias_selecionadas"
            android:layout_width="0px"
            android:layout_weight="2"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:gravity="center"
            android:text="@string/categorias"
            android:textColor="#FFFFFF" />

</LinearLayout>

<ListView
    android:id="@+id/lista_salas_abertas"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/cabecalho_tabela_listar_salas"
    android:layout_alignRight="@+id/cabecalho_tabela_listar_salas"
    android:layout_alignParentBottom="true"
    android:layout_below="@+id/cabecalho_tabela_listar_salas"
    android:fastScrollEnabled="true"
    android:fastScrollAlwaysVisible="true"
    android:scrollbarStyle="outsideInset" >
</ListView>

The problem is: The header is aligned with the ListView's scrollbar, not just the listview. For more illustration, here is my code pictures on facebook: https://www.facebook.com/media/set/?set=a.10204710735749682.1073741826.1275205806&type=1&l=1985f5f7d8

The left picture is what i have. The right one is what i want. Pay attention to the header. I want the header to be aligned with just the listview, not the scrollbar also.

What must i do?


回答1:


Try setting the following to your ListView:

android:scrollbarStyle="outsideOverlay"

If it doesn't work as desired then try with the other options as available here.



来源:https://stackoverflow.com/questions/25735430/android-listview-with-scrollbar-aligned-with-header

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!