中心horizo​​ntaly和/或verticaly与Android的9补丁 [英] Center horizontaly and/or verticaly with 9 patch in Android

查看:112
本文介绍了中心horizo​​ntaly和/或verticaly与Android的9补丁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到话题谈论我的问题,这似乎是我的标准......这让我觉得这是不可能的。但是我给一个尝试。

I can't find a topic talking about my problem which seems to me standard ... And that make me think it is not possible. But I give a try.

我有一个9补丁背景(它包含内容的区域)一个RelativeLayout的。

I have a RelativeLayout with a 9 patch background (which contain a content area).

是可能horizo​​ntaly和/或verticaly中心一个TextView这里面RelativeLayout的有关内容区域?

Is that possible to center horizontaly and/or verticaly a TextView inside this RelativeLayout in relation to the content area ?

推荐答案

该布局文件做任务

<?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/background"
    android:gravity="center" >

    <TextView
        android:id="@+id/txtTest"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Test TextView"
        android:textColor="#000000" >
    </TextView>

</RelativeLayout>

我使用9片图像是

the 9-patch image i used is

这篇关于中心horizo​​ntaly和/或verticaly与Android的9补丁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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