在Android中:如何强制TextView包装内容和填充

在Android中:如何强制TextView包装内容和填充,android,height,padding,Android,Height,Padding,我如何制作TextView\u height=内容\u height+填充 当我向文本框添加一些顶部填充时,它会将内容移到文本视图边框后面。 这是正确的,因为我使TextView与内容一样高 是否可以使文本视图与内容+填充一样高 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:la

我如何制作
TextView\u height=内容\u height+填充
当我向文本框添加一些顶部填充时,它会将内容移到文本视图边框后面。 这是正确的,因为我使TextView与内容一样高

是否可以使文本视图与内容+填充一样高

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
tools:context=".DisplayActivity" >

<TextView
    android:id="@+id/TopmessageStripe"
    style="@style/TopmessageStripeTheme"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:layout_alignWithParentIfMissing="false"
    android:layout_centerHorizontal="true"
    android:height="@dimen/big_margin"
    android:paddingTop="5dp"
    android:text="TextView" />

    </RelativeLayout>


不知道如何使用gui进行操作,但这可能是您在xml中为文本视图寻找的内容

<TextView 
        android:id="@+id/mTextView"
        android:paddingTop="5dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"      
        >
    </TextView>

这很可能是您的问题

android:height="@dimen/big_margin"

它是设置自定义高度,而不是包装内容。

您能粘贴xml定义吗?我就是这么做的。有文本超过文本视图的问题吗?我现在看到了,在添加xml之前我已经发布了这个。Yarakyo是正确的,您设置了两次高度,第二次设置覆盖了第一次设置。