首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android并排查看

Android并排查看
EN

Stack Overflow用户
提问于 2014-01-12 10:49:23
回答 1查看 73关注 0票数 0

我一直在处理一个包含3个textView和一个imageView的布局。所有的一切都应该形成一个正方形。现在看起来是这样的:

我对你的表情很满意。问题在于我的代码,因为视图是用android设置的:布局_边缘化、左/右和顶,如果可能的话,我希望它由android:layout_toLeftOf和toRightOf设置,并在5-10 if左右的所有视图之间留出一个空白。

所以请帮我重写我的代码。

代码语言:javascript
复制
<?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="fill_parent"
android:background="@drawable/background3"
android:orientation="vertical" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:layout_alignParentRight="true"
    android:layout_marginRight="10dp"
    android:layout_marginTop="10dp"
    android:adjustViewBounds="true"
    android:background="#90000000"
    android:cacheColorHint="#00000000"
    android:contentDescription="@string/app_name"
    android:scaleType="fitXY"
    android:src="@drawable/ic_launcher" />

<RelativeLayout
    android:id="@+id/relativeLayout2"
    android:layout_width="80dp"
    android:layout_height="80dp"
    android:layout_alignParentRight="true"
    android:layout_marginRight="10dp"
    android:layout_marginTop="100dp"
    android:background="#90000000"
    android:cacheColorHint="#00000000"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/img"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:layout_alignParentRight="true"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="0dp"
        android:layout_marginTop="0dp"
        android:contentDescription="@string/app_name"
        android:scaleType="centerCrop" />

</RelativeLayout>

    <TextView
        android:id="@+id/title"
        android:layout_width="285dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_marginTop="100dp"
        android:background="#90000000"
        android:ellipsize="end"
        android:maxLines="2"
        android:textColor="#E97305"
        android:textSize="17sp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/detail"
        android:layout_width="285dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:background="#90000000"
        android:cacheColorHint="#00000000"
        android:layout_marginTop="123dp"
        android:textColor="#ffffff" 
        android:paddingBottom="22dp"/>
    <TextView
        android:id="@+id/footer"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"      
        android:layout_marginLeft="5dp"
        android:background="#90000000"
        android:cacheColorHint="#00000000"
        android:layout_marginRight="5dp"
        android:layout_marginTop="185dp"
        android:textColor="#ffffff" />

</RelativeLayout>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-01-12 12:32:19

你可以试试这个:

代码语言:javascript
复制
<?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="fill_parent"
android:background="@drawable/background3"
android:orientation="vertical" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:layout_alignParentRight="true"
    android:layout_marginRight="10dp"
    android:layout_marginTop="10dp"
    android:adjustViewBounds="true"
    android:background="#90000000"
    android:cacheColorHint="#00000000"
    android:contentDescription="@string/app_name"
    android:scaleType="fitXY"
    android:src="@drawable/ic_launcher" />

<RelativeLayout
    android:id="@+id/relativeLayout2"
    android:layout_width="80dp"
    android:layout_height="80dp"
    android:layout_alignParentRight="true"
    android:layout_marginRight="5dp"
    android:layout_marginTop="100dp"
    android:background="#90000000"
    android:cacheColorHint="#00000000"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/img"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:layout_marginBottom="0dp"
        android:layout_marginTop="0dp"
        android:contentDescription="@string/app_name"
        android:scaleType="centerCrop" />

</RelativeLayout>

    <TextView
        android:id="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@id/relativeLayout2"
        android:layout_alignTop="@id/relativeLayout2"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_toLeftOf="@id/relativeLayout2"
        android:background="#90000000"
        android:ellipsize="end"
        android:maxLines="2"
        android:textColor="#E97305"
        android:textSize="17sp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/detail"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/title"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_marginTop="5dp"
        android:background="#90000000"
        android:cacheColorHint="#00000000"
        android:paddingBottom="22dp"
        android:textColor="#ffffff" />

    <TextView
        android:id="@+id/footer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/detail"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_marginTop="5dp"
        android:background="#90000000"
        android:cacheColorHint="#00000000"
        android:textColor="#ffffff" />

</RelativeLayout>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21073750

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档