如何放置在Android的两个图像之间的文本 [英] How to place a text between two images in Android

查看:96
本文介绍了如何放置在Android的两个图像之间的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建的布局在那里我有两个图像在左,在中间偏右和文字。

I want to create layout where I have two images at left and at right and text in center.

我曾尝试与相对布局做,但偏偏它是失败。任何人可以给我一个例子吗?

I have tried to do it with relative layout but unfortunetly it was unsuccessfully. Could anybody provide me an example?

推荐答案

你有没有尝试过的东西怎么样?

Have you tried something like?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <ImageView
        android:id="@+id/img1"
        android:layout_width="50dip"
        android:layout_height="50dip"
        android:layout_alignParentLeft="true"
        android:src="@drawable/image1"/>
    <ImageView
        android:id="@+id/img2"
        android:layout_width="50dip"
        android:layout_height="50dip"
        android:layout_alignParentRight="true"
        android:src="@drawable/image2"/>
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/img1"
        android:layout_toLeftOf="@id/img2"
        android:layout_alignTop="@id/img1"
        android:text="I'm between!"/>
</RelativeLayout>

如果你不需要对你的看法更多的事情,你可以想使用的LinearLayout 来代替,因为它更容易实现。在这种情况下,你就必须用 layout_weight 属性的发挥。

If you don't need more things on your view, you could want to use LinearLayout instead, since it's more easier to implement. In that case, you just have to play with the layout_weight attribute.

这篇关于如何放置在Android的两个图像之间的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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