片段内的Android ListView被切断 [英] Android ListView inside Fragment gets cut off

查看:71
本文介绍了片段内的Android ListView被切断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Fragment内使用ListView.我的ListView的项目是使用自定义适配器"动态加载的.

I am using a ListView inside a Fragment. The items of my ListView are dynamically loaded using a Custom Adapter.

我注意到,当我尝试将项目的字体大小设置得较大(例如28dp)时,列表视图仍将呈现,但将在末尾被截断,因此最后一个项目将不可见.

I notice that when I try to set the Font size of my items something large ( like 28dp ) , the listview will still render but will get cut off at the end so the last item will not be visible.

这是ListView

Here is the ListView

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:id="@+id/layoutList"
        >
        <ListView
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:id="@+id/listView"
            android:stackFromBottom="true"
        />
</LinearLayout>

和项目行

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="80dp"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:text="TextView"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="0"
        android:id="@+id/txtHours"
        android:layout_alignParentTop="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:textSize="28dp" />

</RelativeLayout>

我的实现有什么问题吗?

is there anything wrong with my implementation ?

推荐答案

,您需要在布局中添加填充和权重.当将较大尺寸的项目放置在布局中时,其他视图将被忽略,因此您会看到列表视图被切除. 请参考以下链接: http://developer.android.com/guide/topics/ui /layout/linear.html#Weight

you need to add padding and weights to your layouts. When an item of bigger size is placed in the layout the other view are over looked and hence you see the listview cuts off. Please refer to the below link : http://developer.android.com/guide/topics/ui/layout/linear.html#Weight

希望它为您提供有关如何设计列表视图布局的想法.

Hope it gives you an idea on how to design you listview layout.

这篇关于片段内的Android ListView被切断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆