列表视图行重叠问题 [英] Listview Row Overlap Problem

查看:105
本文介绍了列表视图行重叠问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚更新了我的应用程序,我得到的人谁更新一些奇怪的投诉。我只是从人与非股票Android手机(手机制造商已经修改了... HTC手机,CLIQ,脉搏等),其他手机一样的Droid和Nexus做工精细的抱怨。我的应用程序(相框豪华)中有一个图片浏览,文本视图,视图(间隔)和复选框,成一排列表。会发生什么情况的受影响电话是该行开始重叠和它减少一切掉的上半部分。我的布局code因为这是下面,我拉我的头发就这一点,我可能有错误的此布局。
为什么在某些手机上,而不是别人这项工作?任何帮助将是AP preciated。

行布局:

 <?XML版本=1.0编码=UTF-8&GT?;
<的LinearLayout
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =WRAP_CONTENT
    机器人:方向=横向>
< ImageView的
    机器人:ID =@ + ID / photorowIcon
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_gravity =center_vertical
    机器人:paddingTop =10dp
    机器人:paddingBottom会=10dp
    机器人:paddingRight =5DP
    />
<的TextView
    机器人:ID =@ + ID / photorowText
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_gravity =center_vertical
    />
<查看
    机器人:layout_width =0像素
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_weight =1/>
<复选框
    机器人:ID =@ + ID / photorowCheckBox
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_gravity =center_vertical
    机器人:可聚焦=假
    机器人:focusableInTouchMode =假
    />
< / LinearLayout中>

布局行插入:

 <?XML版本=1.0编码=UTF-8&GT?;
<的LinearLayout
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT
    机器人:方向=垂直>
<的LinearLayout
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =WRAP_CONTENT
    机器人:背景=@绘制/ title1_gradient
    机器人:方向=垂直>
<的TextView
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =WRAP_CONTENT
    机器人:文字=选择照片显示:
    机器人:TEXTSIZE =20SP
    机器人:文字样式=大胆
    机器人:文字颜色=#FFFFFFFF
    机器人:paddingLeft =5DP
    机器人:paddingRight =5DP
    机器人:paddingTop =5DP
    />
<的TextView
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =WRAP_CONTENT
    机器人:ID =@ + ID / FOLDERNAME
    机器人:TEXTSIZE =15sp
    机器人:文字样式=大胆
    机器人:文字颜色=#FFFFFFFF
    机器人:paddingLeft =5DP
    机器人:paddingRight =5DP
    机器人:paddingBottom会=5DP
    />
    <查看
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =1像素
        机器人:背景=#406C6C6C/>
    < / LinearLayout中>
< ListView控件
    机器人:ID =@机器人:ID /列表
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =0像素
    机器人:layout_weight =1
    机器人:drawSelectorOnTop =假
    机器人:paddingLeft =5DP
    机器人:paddingRight =5DP
    />
<的LinearLayout
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT
        机器人:方向=垂直
        机器人:layout_gravity =底>
    <的LinearLayout
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:方向=横向
            机器人:layout_gravity =底
            机器人:背景=#FF6C6C6C
            机器人:填充=5DP>
            <按钮
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:ID =@ + ID / OK
                机器人:文字=OK/>
    < / LinearLayout中>
< / LinearLayout中>
< / LinearLayout中>


解决方案

我有同样的问题。很明显对2的Verizon阋,并在1.5模拟器。它不会在一个G1(V1.6),一个摩托的Droid(2.0.1),或任何模拟器1.6 +

出现

有发生结合到ListActivity一个ListView内,并且在一个垂直取向的LinearLayout。在这两种情况下,我喂RelativeLayouts到每个和我一直在失去他们的顶部

我用hierarchyViewer,与每一个该死的事情打乱,并转过身。它最后我恍然大悟,后的RelativeLayout的手动设置了minHeight到的东西比什么是显示更大,这个问题不只是上浆,但换档。在RelativeLayout的一切都得到推过去认为的顶部。

这让我精神上重温圣杜斯的上面的回答:是与重力

在RelativeLayout的(住房每个表的行),我把:

 安卓重力=center_vertical

此作出了巨大的差异。

现在,我行的还是的看在1.5较窄,但他们是有用的,而且我可以保持它

I just updated my app and I am getting some odd complaints from people who update it. I am only getting complaints from people with non-stock android phones (phones that manufacturers have modified...HTC phones, cliq, pulse, etc), other phones like the Droid, Nexus work fine. My app (Photo Frame Deluxe) has a list in it with a Image View, Text View, View (spacer) and checkbox, all in a row. What happens on the affected phones is that the rows start overlapping and it cuts the top half of everything off. My layout code for this is below, I am pulling my hair out on this, what might I have wrong in this layout. Why does this work on some phones and not on others? Any help would be appreciated.

Row Layout:

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

Layout Row is inserted in:

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

解决方案

I had the same problem. It was evident on 2 Verizon Eris, and in the 1.5 simulator. It does NOT occur in a G1 (v1.6), a moto Droid (2.0.1), or any simulator 1.6+

It occurred within a ListView bound to a ListActivity, and in a vertically oriented LinearLayout. In both cases, I was feeding RelativeLayouts into each, and i kept losing the tops of them

I used the hierarchyViewer, mucked with every damn thing, and spun around. It finally dawned on me, after manually setting minHeight on the RelativeLayout to something larger than what was showing, that the problem wasn't just SIZING, but SHIFTING.. Everything in the RelativeLayout was getting pushed past the top of the view.

This made me mentally revisit sandos's answer above: "something to do with gravity"

in the RelativeLayout (housing each 'row' of the lists), i put:

android:gravity="center_vertical"

this made an enormous difference.

Now, my rows still look narrower in 1.5, but they are usable, and I can keep at it

这篇关于列表视图行重叠问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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