【发布时间】:2011-09-01 11:07:30
【问题描述】:
我有一个相对布局,其中包含图像、文本视图、图像的顺序。我打开了左对齐的左图像。右图打开了父对齐。并且打开了对齐中心父的文本视图。问题是,虽然所有内容在技术上都正确对齐,但 textview 虽然包含一个值,但已减少到布局中间的基本垂直线。为什么 textview 不根据其内容保持其宽度?谢谢
【问题讨论】:
标签: android width textview android-relativelayout
我有一个相对布局,其中包含图像、文本视图、图像的顺序。我打开了左对齐的左图像。右图打开了父对齐。并且打开了对齐中心父的文本视图。问题是,虽然所有内容在技术上都正确对齐,但 textview 虽然包含一个值,但已减少到布局中间的基本垂直线。为什么 textview 不根据其内容保持其宽度?谢谢
【问题讨论】:
标签: android width textview android-relativelayout
试试这个
<?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>
【讨论】:
检查你的图像视图的宽度。将这 3 个东西的宽度设置为“包装内容”。
【讨论】: