0

我刚刚更新了我的应用程序,我收到了更新它的人的一些奇怪的抱怨。我只收到非库存 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>
4

3 回答 3

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 中的所有内容都被推到了视图的顶部。

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

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

android:gravity="center_vertical"

这产生了巨大的影响。

现在,我的行在1.5 中看起来仍然更窄,但它们是可用的,我可以坚持下去

于 2010-03-18T22:29:18.660 回答
1

更改您的 listView 标签属性

android:layout_height="fill_parent"
于 2010-02-27T09:52:11.543 回答
0

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

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

于 2010-02-04T20:37:49.470 回答