Android Textview在两个图像之间的RelativeLayout中没有宽度

Android Textview在两个图像之间的RelativeLayout中没有宽度,android,width,textview,android-relativelayout,Android,Width,Textview,Android Relativelayout,我有一个relativelayout,图像,文本视图,图像按顺序排列。我打开了左对齐父对象的左图像。右侧图像已启用“父右侧对齐”。和启用“对齐中心父对象”的文本视图。问题是,尽管所有技术在技术上都是正确对齐的,但是TeTVIEW在包含一个值的同时,已经在布局中间被简化为垂直线。为什么textview不根据内容保持其宽度?谢谢你试试这个 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http

我有一个relativelayout,图像,文本视图,图像按顺序排列。我打开了左对齐父对象的左图像。右侧图像已启用“父右侧对齐”。和启用“对齐中心父对象”的文本视图。问题是,尽管所有技术在技术上都是正确对齐的,但是TeTVIEW在包含一个值的同时,已经在布局中间被简化为垂直线。为什么textview不根据内容保持其宽度?谢谢你试试这个

<?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>

试试这个

<?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>


检查您的图像视图的宽度。将这三个东西的宽度设置为“包裹内容”。

检查您的图像视图的宽度。将这三个东西的宽度设置为“包裹内容”。

这很有效,谢谢!但是有点令人不安,因为中间的文本视图中的文本一直移到右图像而不是中心。但仅在designer视图中。当它安装在我的手机上时,它是居中的。让我有点紧张…好像我无法完全控制它。这可能是设计师的问题,因为在我的设计师看来,它没有与图像重叠。这很有效,谢谢!但是有点令人不安,因为中间的文本视图中的文本一直移到右图像而不是中心。但仅在designer视图中。当它安装在我的手机上时,它是居中的。让我有点紧张…好像我没有完全控制它。这可能是设计师的问题,因为在我的设计师看来,它没有重叠的形象。