XML布局行为异常的android [英] xml layout behaves abnormal android

查看:156
本文介绍了XML布局行为异常的android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设计一个自定义的列表视图,其中容纳许多子视图。在有其行为异常的两个子视图

I am designing a custom listview , which hold many child view . In that there is two child views which behaves abnormal


  1. 如果变成值个位数,那么视图获取转移到左侧

  2. 我一直希望十二生肖或石头的形象图标始终3dip留有余量的十二生肖或石TextView的价值,让价值和形象与3dip。但留有余量不工作侧出现的一面,所以我设置为右页边距

list_row.xml

list_row.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dip" >

<LinearLayout
    android:id="@+id/list_row"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_marginRight="5dip"
    android:background="@drawable/image_bg"
    android:padding="3dip" >

    <ImageView
        android:id="@+id/list_image"
        android:layout_width="85dip"
        android:layout_height="80dip"
        android:scaleType="fitXY"
        android:shadowColor="#585858"
        android:shadowDx="0.0"
        android:shadowDy="0.0"
        android:shadowRadius="20"
        android:src="@drawable/karthik" />
</LinearLayout>

<ImageView
    android:id="@+id/ImageView02"
    android:layout_width="15dip"
    android:layout_height="15dip"
    android:layout_alignLeft="@+id/list_row"
    android:layout_below="@+id/list_row"
    android:contentDescription="Zodiac icon"
    android:scaleType="fitXY"
    android:shadowColor="#8B4513"
    android:src="@drawable/rings_icon" 
    android:layout_marginRight="0dip"/>

<TextView
    android:id="@+id/title_name"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/list_row"
    android:layout_toRightOf="@+id/list_row"
    android:text="KARTHIK.KOLANJI"
    android:textColor="#181818"
    android:textSize="16dip"
    android:textStyle="bold"
    android:typeface="sans" />

<TextView
    android:id="@+id/sub_title_category"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_marginRight="5dip"
    android:gravity="right"
    android:text="Facebook Friend"
    android:textColor="#10bcc9"
    android:textSize="12dip"
    android:textStyle="bold" />

<TextView
    android:id="@+id/TextView04"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignRight="@+id/txtview_turns"
    android:layout_below="@+id/txtview_turns"
    android:text=" days  left"
    android:textColor="#996600"
    android:textSize="9sp"
    android:textStyle="bold" 
    android:layout_marginTop="2dip"/>

<TextView
    android:id="@+id/list_image_arrow"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignRight="@+id/sub_title_category"
    android:layout_below="@+id/title_name"
    android:text="t u r n s"
    android:textColor="#996600"
    android:textSize="9sp"
    android:textStyle="bold" />

<TextView
    android:id="@+id/txtview_turns"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/list_image_arrow"
    android:layout_below="@+id/list_image_arrow"
    android:text="24"
    android:textColor="#990000"
    android:textSize="27sp"
    android:textStyle="normal" />

<TextView
    android:id="@+id/txtview_next_bd"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/TextView01"
    android:layout_alignBottom="@+id/TextView01"
    android:layout_marginLeft="5dp"
    android:layout_toRightOf="@+id/TextView01"
    android:text="Wednesday"
    android:textColor="#CC0000"
    android:textSize="15sp"
    android:textStyle="bold" />

<TextView
    android:id="@+id/txtview_zodiac"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/TextView02"
    android:layout_alignBottom="@+id/TextView02"
    android:layout_toRightOf="@+id/TextView02"
    android:text="Sagittarius"
    android:textColor="#CC0000"
    android:textSize="15sp"
    android:textStyle="normal" 
    />

<TextView
        android:id="@+id/txtview_type_of_reminder"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/ImageView02"
        android:layout_toRightOf="@+id/ImageView02"
        android:text="(Anniversary)"
        android:textColor="#787878"
        android:textSize="13sp"
        android:textStyle="normal" />

<ImageView
    android:id="@+id/ImageView01"
    android:layout_width="20dip"
    android:layout_height="20dip"
    android:layout_above="@+id/txtview_next_bd"
    android:layout_toLeftOf="@+id/TextView04"
    android:contentDescription="Zodiac icon"
    android:scaleType="fitXY"
    android:shadowColor="#8B4513"
    android:shadowDx="0.0"
    android:shadowDy="0.0"
    android:shadowRadius="20"
    android:src="@drawable/scroll" 
    android:layout_marginRight="50dip"/>

<TextView
    android:id="@+id/sub_title_contact_number"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/title_name"
    android:layout_alignTop="@+id/list_image_arrow"
    android:text="9594080469"
    android:textColor="#181818"
    android:textSize="15dip" />

<TextView
    android:id="@+id/sub_title_birthdate"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/txtview_turns"
    android:layout_alignBottom="@+id/txtview_turns"
    android:layout_alignLeft="@+id/sub_title_contact_number"
    android:text="7th, April 1990"
    android:textColor="#181818"
    android:textSize="15dip" />

<TextView
    android:id="@+id/TextView02"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/sub_title_birthdate"
    android:layout_below="@+id/txtview_turns"
    android:text="Zodiac :  "
    android:textColor="#181818"
    android:textSize="15sp"
    android:textStyle="normal" />

<TextView
    android:id="@+id/txtview_days_left"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/txtview_type_of_reminder"
    android:layout_alignBottom="@+id/txtview_type_of_reminder"
    android:layout_alignRight="@+id/TextView04"
    android:text="36"
    android:textColor="#990000"
    android:textSize="27sp"
    android:textStyle="normal" />

<TextView
    android:id="@+id/TextView01"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/txtview_type_of_reminder"
    android:layout_alignBottom="@+id/txtview_type_of_reminder"
    android:layout_alignLeft="@+id/TextView02"
    android:text="Birthday on : "
    android:textColor="#181818"
    android:textSize="15sp"
    android:textStyle="normal" />

 </RelativeLayout>

下面的屏幕截图

推荐答案

我可以建议的LinearLayout 而不是 RelativeLayout的
我发现 RelativeLayout的给有很多孩子靠不住的结果。 (特别是当内容被添加编程)试试这个:

Might I suggest LinearLayout instead of RelativeLayout? I've found RelativeLayout to give wonky results with lots of children. (Especially when the content is added programatically) Try this instead:

的LinearLayout &LT;集装箱为内容的主体 Orientation.VERTICAL

LinearLayout < Container for the body of your content Orientation.VERTICAL

的LinearLayout &LT;内容的新行 Orientation.HORIZONTAL

LinearLayout < New Row of Content Orientation.HORIZONTAL

有关内容的每一个新的行,将其放置在第二放在的LinearLayout 键,将其作为第一个孩子。

For every new row of content, place it inside of the second LinearLayout and make it a child of the first.

我怀疑你的问题将很快消失。

I suspect your issues will disappear quickly.

这篇关于XML布局行为异常的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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