2012-07-16 69 views
1

我找不到一個話題談論我的問題,這在我看來標準...這讓我覺得這是不可能的。但我試了一下。中心horizo​​ntaly和/或verticaly與9補丁在Android

我有一個9個補丁背景(其中包含一個內容區域)的RelativeLayout。

這是可能的中心horizo​​ntaly和/或verticaly在這個RelativeLayout相對於內容區域的TextView?

+0

yes.canüPLS烏拉圭回合後的xm​​l文件? – AkashG 2012-07-16 09:55:43

+0

這是可能的......但不是沒有你的XML .. :) – 2012-07-16 09:59:36

+0

我不能現在,你必須等待7小時,因爲我是新的...和XML在評論是醜陋的... – azerto00 2012-07-16 10:46:24

回答

2

該佈局文件將做任務

<?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修補圖像是

enter image description here

+0

我幾乎肯定我試着用重力=「中心」。也許我想念它..謝謝! – azerto00 2012-07-16 12:24:14

+0

我遇到了相對佈局和centerinparent/vertical/horizo​​ntal忽略內容區域的問題。這是解決這個問題的方法,謝謝! – 2013-05-24 00:08:08