【问题标题】:Listview Row Overlap ProblemListview 行重叠问题
【发布时间】:2011-01-13 03:39:32
【问题描述】:

我刚刚更新了我的应用程序,我收到了更新它的人的一些奇怪的投诉。我只收到非库存 android 手机(制造商修改过的手机......HTC 手机、cliq、pulse 等)的投诉,其他手机如 Droid、Nexus 工作正常。我的应用程序(豪华相框)中有一个列表,其中包含图像视图、文本视图、视图(间隔)和复选框,所有这些都在一行中。在受影响的手机上发生的情况是,行开始重叠,它切断了所有内容的上半部分。我的布局代码在下面,我在这个问题上大发雷霆,我在这个布局中可能有什么问题。 为什么这在某些手机上有效,而在其他手机上无效?任何帮助将不胜感激。

行布局:

<?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="wrap_content"
    android:orientation="horizontal">
<ImageView
    android:id="@+id/photorowIcon"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:paddingTop="10dp"
    android:paddingBottom="10dp"
    android:paddingRight="5dp"
    />
<TextView
    android:id="@+id/photorowText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    />
<View
    android:layout_width="0px"
    android:layout_height="wrap_content"
    android:layout_weight="1"/>
<CheckBox
    android:id="@+id/photorowCheckBox"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:focusable="false"
    android:focusableInTouchMode="false"
    />  
</LinearLayout>

布局行插入:

<?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">
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/title1_gradient"
    android:orientation="vertical">
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Select Photos to Display:"
    android:textSize="20sp"
    android:textStyle="bold"
    android:textColor="#FFFFFFFF"
    android:paddingLeft="5dp"
    android:paddingRight="5dp"
    android:paddingTop="5dp"
    />
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/folderName"
    android:textSize="15sp"
    android:textStyle="bold"
    android:textColor="#FFFFFFFF"
    android:paddingLeft="5dp"
    android:paddingRight="5dp"
    android:paddingBottom="5dp"
    />
    <View
        android:layout_width="fill_parent"
        android:layout_height="1px"
        android:background="#406C6C6C"/>
    </LinearLayout>
<ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="0px"
    android:layout_weight="1"
    android:drawSelectorOnTop="false"
    android:paddingLeft="5dp"
    android:paddingRight="5dp"
    />
<LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_gravity="bottom">    
    <LinearLayout 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:layout_gravity="bottom"
            android:background="#FF6C6C6C" 
            android:padding="5dp">
            <Button
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:id="@+id/ok"
                android:text="OK"/>
    </LinearLayout>
</LinearLayout>
</LinearLayout>

【问题讨论】:

  • 你有你的用户看到的效果的截图吗?

标签: android listview layout row


【解决方案1】:

我无法确定您的问题,但我知道布局(很遗憾!)可能会在 Android 的次要版本之间发生变化。我看到从 1.5 到 1.6 的一些问题,特别是列表中的布局。更成问题的是模拟器没有正确模拟这一点,这使得这很难修复。我记得它与重力有关,所以我会玩那个部分。此外,请尝试使用相对布局,因为它比嵌套线性布局占用更少的资源。

还可以尝试使用 SDK、layoutopt 和 Hiearhcy Viewer 中的布局工具。

【讨论】:

    【解决方案2】:

    改变你的listView标签属性

    android:layout_height="fill_parent"
    

    【讨论】:

      【解决方案3】:

      我遇到了同样的问题。这在 2 Verizon Eris 和 1.5 模拟器中很明显。它不会出现在 G1 (v1.6)、moto Droid (2.0.1) 或任何模拟器 1.6+

      它发生在绑定到 ListActivity 的 ListView 和垂直方向的 LinearLayout 中。在这两种情况下,我都将 RelativeLayouts 输入到每个中,并且我一直在丢失它们的顶部

      我使用了hierarchyViewer,处理了所有该死的东西,然后转了一圈。在将 RelativeLayout 上的 minHeight 手动设置为大于显示的值之后,我终于明白了,问题不仅仅是 SIZING,而是 SHIFTING..RelativeLayout 中的所有内容都被推到了视图的顶部。

      这让我在精神上重新审视了上面 sandos 的回答:“与重力有关”

      在RelativeLayout(包含列表的每个“行”)中,我输入:

      android:gravity="center_vertical"
      

      这带来了巨大的变化。

      现在,我的行仍然在 1.5 中看起来更窄,但它们是可用的,我可以继续使用它

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-11-22
        • 2011-01-22
        • 2013-11-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多