2011-05-25 80 views
0

我有一個圖片,textview,圖片的相關佈局。打開左對齊左側圖像。正確的圖像已打開父對齊權。對齊中心父級的文本視圖打開。問題是,雖然所有東西在技術上都是正確對齊的,但是textview在包含一個值的時候,已經減少到佈局中間的一條垂直線。爲什麼textview沒有根據其內容保持寬度?謝謝Textview在2張圖片之間的RelativeLayout中沒有寬度

回答

2

試試這個

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" android:layout_height="wrap_content"> 
    <RelativeLayout android:layout_height="match_parent" 
     android:id="@+id/RelativeLayout01" android:layout_width="fill_parent"> 
     <ImageView android:layout_width="wrap_content" android:src="@drawable/icon" 
      android:layout_height="wrap_content" android:id="@+id/ImageView01" 
      android:layout_alignParentLeft="true"></ImageView> 
     <TextView android:layout_width="wrap_content" 
      android:layout_height="wrap_content" android:id="@+id/TextView01" 
      android:layout_centerInParent="true" android:layout_centerVertical="true" 
      android:text=" sdfsdf sdhfhskdhfkh hsdkfhksdhfh shdfkhsdkhfkjsdh fhskdfhksdhfjk sdfhsdkhfkjsdfhkhasdhfksa fsakhdfhsdfhkshdf skdhfkshdfk" 
      android:layout_toRightOf="@+id/ImageView01" android:layout_toLeftOf="@+id/ImageView02"></TextView> 
     <ImageView android:layout_width="wrap_content" android:src="@drawable/icon" 
      android:layout_height="wrap_content" android:id="@+id/ImageView02" 
      android:layout_alignParentRight="true"></ImageView> 
    </RelativeLayout> 
</LinearLayout> 
+0

This Works,thanks!但是,有點令人不安,因爲中間的textview中的文本一直轉移到正確的圖像而不是居中。但只有在設計師看來。當它安裝在我的手機上時,它居中。讓我有點緊張......就像我沒有完全控制它。 – Metallicraft 2011-05-26 00:51:58

+0

它可能是設計者的問題,因爲在我的設計師看來,它並沒有與圖像重疊。 – 2011-05-26 05:00:12

1

檢查烏爾imageviews..set的寬度的三件事爲「包裝內容」的寬度。

相關問題