2011-05-25 45 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的宽度的三件事为“包装内容”的宽度。