android UI布局不正确

时间:2013-10-01 04:12:24

标签: android layout view

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@color/general_detail" >

    <RelativeLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
    <!-- 标题栏 -->
        <include layout="@layout/general_menu_title_bar"/>     

        <!-- 地图 -->
        <ImageView 
            android:layout_width="@dimen/fast_map_w"
            android:layout_height="@dimen/fast_map_h"
            android:scaleType="fitXY"
            android:src="@drawable/selector_ic_fast_food_map"
            android:layout_alignParentRight="true"
            android:layout_marginRight="@dimen/fast_map_m_r"
            android:layout_centerVertical="true"
            android:id="@+id/map"/>

    </RelativeLayout>


    <!-- 分类 -->
    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="@dimen/fast_sort_layout_h"
        android:background="#DDD"
        android:orientation="horizontal">

        <!-- 地区 -->
        <RelativeLayout 
            android:layout_width="fill_parent"
            android:layout_height="@dimen/fast_sort_layout_h"
            android:layout_weight="1"
            android:background="@drawable/selector_pretakout"
            android:id="@+id/region_layout">
             <TextView 
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:textSize="@dimen/fast_sort_text"
                android:gravity="center"
                android:text="地区"
                android:id="@+id/region"/>
             <ImageView 
                 android:layout_width="@dimen/fast_sort_ant_size"
                 android:layout_height="@dimen/fast_sort_ant_size"
                 android:scaleType="fitXY"
                android:layout_alignParentTop="true"
                 android:layout_alignParentRight="true"
                 android:layout_marginTop="@dimen/fast_sort_ant_m_t"
                 android:layout_marginRight="@dimen/fast_sort_ant_m_r"
                 android:src="@drawable/selector_ic_trangle"/>
        </RelativeLayout>

        <!-- 类型 -->
        <RelativeLayout 
            android:layout_width="fill_parent"
            android:layout_height="@dimen/fast_sort_layout_h"
            android:layout_weight="1"
            android:background="@drawable/selector_pretakout"
            android:id="@+id/category_layout">
             <TextView 
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:textSize="@dimen/fast_sort_text"
                android:gravity="center"
                android:text="类型"
                android:id="@+id/category"/>

             <ImageView 
                 android:layout_width="@dimen/fast_sort_ant_size"
                 android:layout_height="@dimen/fast_sort_ant_size"
                 android:scaleType="fitXY"
                 android:layout_alignParentTop="true"
                 android:layout_alignParentRight="true"
                 android:layout_marginTop="@dimen/fast_sort_ant_m_t"
                 android:layout_marginRight="@dimen/fast_sort_ant_m_r"
                 android:src="@drawable/selector_ic_trangle"/>
        </RelativeLayout>

    </LinearLayout>

    <!-- 列表 -->
    <com.hy.liang.crazydirection.view.RefreshListView
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="@color/general_detail"
          android:dividerHeight="0dp"
          android:divider="@color/general_detail"
          android:fadingEdge="none"
          android:id="@+id/listview"/>
</LinearLayout>

这些代码在大多数设备上运行,结果是正确的: enter image description here

但是在GALAXY Note I9220上运行,有一个问题是矩形图像对齐底部不是我想要的!  enter image description here 有没有人可以帮我解决这个问题? 非常感谢!

2 个答案:

答案 0 :(得分:0)

从三角形图片视图中移除android:layout_marginRight="@dimen/fast_sort_ant_m_r"

已编辑:

尝试更改:

<ImageView 
    android:layout_width="@dimen/fast_sort_ant_size"
    android:layout_height="@dimen/fast_sort_ant_size"
    android:scaleType="fitXY"
    android:layout_alignParentTop="true"
    android:layout_alignParentRight="true"
    android:layout_marginTop="@dimen/fast_sort_ant_m_t"
    android:layout_marginRight="@dimen/fast_sort_ant_m_r"
    android:src="@drawable/selector_ic_trangle"/>

致:

<ImageView 
    android:layout_width="@dimen/fast_sort_ant_size"
    android:layout_height="@dimen/fast_sort_ant_size"
    android:scaleType="fitXY"
    android:layout_alignBottom="@id/region"
    android:layout_alignRight="@id/region"
    android:layout_marginTop="@dimen/fast_sort_ant_m_t"
    android:layout_marginRight="@dimen/fast_sort_ant_m_r"
    android:src="@drawable/selector_ic_trangle"/>

请务必在必要时将@id / region更改为类别

答案 1 :(得分:0)

这只是问题布局的示例:

enter image description here

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/black"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="100dip"
        android:background="#DDD"
        android:orientation="horizontal"
        android:weightSum="2" >

        <RelativeLayout
            android:layout_width="0dip"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:background="@color/note_text_disabled" >

            <TextView
                android:id="@+id/txt_first"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:layout_centerInParent="true"
                android:text="标题栏"
                android:gravity="center"
                android:textColor="@color/white" />

            <ImageView
                android:layout_width="30dip"
                android:layout_height="30dip"
                android:layout_alignParentBottom="true"
                android:layout_alignParentRight="true"
                android:layout_marginBottom="5dip"
                android:layout_marginRight="5dip"
                android:src="@drawable/back_arrow" />
        </RelativeLayout>

         <RelativeLayout
            android:layout_width="0dip"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:background="@color/note_text_disabled" >

            <TextView
                android:id="@+id/txt_first"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:layout_centerInParent="true"
                android:text="标题栏"
                android:gravity="center"
                android:textColor="@color/white" />

            <ImageView
                android:layout_width="30dip"
                android:layout_height="30dip"
                android:layout_alignParentBottom="true"
                android:layout_alignParentRight="true"
                android:layout_marginBottom="5dip"
                android:layout_marginRight="5dip"
                android:src="@drawable/back_arrow" />
        </RelativeLayout>
    </LinearLayout>

</LinearLayout>

根据您的需要更改xml希望它会有所帮助。