开发者

Textview has no width in RelativeLayout between 2 images

I have a relativelayout with an image, textview, image in that order. I have the left image with parent align left turned on. The right image has parent align right turned on. And the textview with align center parent turned on. The problem is that while everything is technically aligned correctly, the textview, while containing a value, has been reduced to basically a vertic开发者_C百科al line in the middle of the layout. Why isn't the textview keeping its width based on its content? Thank


try this

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


check the width of ur imageviews..set the width of those 3 things as 'wrap content'.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜