【问题标题】:Textview's text is owerflow background of the buttonTextview文本是按钮的溢出背景
【发布时间】:2012-05-23 14:30:27
【问题描述】:

我有一个 textview 和一个按钮,当我的 textview 的文本填充长句时,它填充了按钮的背景。我应该怎么做才能解决它?

Textview 是“dosyaAdi”,按钮是“buttonEkIndir”

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="0.03"
    android:background="#ededed" >

    <TextView
        android:id="@+id/txtKimden"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="5dp"
        android:text="Small Text"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textColor="@android:color/black"
        android:textSize="20dp" />

    <TextView
        android:id="@+id/txtKonu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/txtKimden"
        android:layout_marginLeft="10dp"
        android:text="Small Text"
        android:ellipsize="end"
        android:maxLines="3"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textColor="@android:color/black"
        android:textSize="17dp" />

    <ImageView
        android:id="@+id/imageViewAttachment"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/txtKonu"
        android:layout_marginLeft="10dp"
        android:src="@drawable/ic_email_attachment65x30" />

    <TextView
        android:id="@+id/dosyaAdi"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/imageViewAttachment"
        android:layout_toRightOf="@+id/imageViewAttachment"

        android:text="Small Text"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textColor="@android:color/black"
        android:textSize="17dp" />

    <TextView
        android:id="@+id/txtTarih"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/txtKimden"
        android:layout_alignBottom="@+id/txtKimden"
        android:layout_alignParentRight="true"
        android:layout_marginRight="10dp"
        android:text="Small Text"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textColor="@android:color/black"
        android:textSize="15dp" />

    <TextView
        android:id="@+id/txtSaat"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/txtTarih"
        android:layout_below="@+id/txtTarih"
        android:text="Small Text"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textColor="@android:color/black"
        android:textSize="15dp" />

    <Button
        android:id="@+id/buttonEkIndir"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="70dip"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/dosyaAdi"
        android:layout_alignBottom="@+id/dosyaAdi"
        android:layout_alignLeft="@+id/txtSaat"
        android:text="İndir" />

</RelativeLayout>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#ededed" >
</RelativeLayout>

<WebView
    android:id="@+id/webvGovde"
    android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:layout_weight="1" />

对于这个:

“txtKonu”是左一,“txtSaat”是右一

【问题讨论】:

    标签: android button textview


    【解决方案1】:

    您可以将 android:layout_toLeftOf="@id/buttonEkIndir 添加到违规的 dosyaAdi。

    但是,这意味着即使文本位于按钮下方,文本也会保留在按钮的左侧(不确定这对您是否重要,只是想我会提到它)。

    编辑

    第二个添加 android:layout_toLeftOf="@id/txtSaat 到 txtKonu。

    【讨论】:

      【解决方案2】:

      除了其他人提供的布局调整解决方案之外,我认为您还应该在 TextView 中设置以下内容,因为显示这么长的文件名毫无用处:)

      android:ellipsize="end"
      android:singleLine="true"
      

      【讨论】:

      • +1,我想提这些,但不确定他是否想要显示完整的文件名,所以只解决了他报告的问题。 :)
      【解决方案3】:

      看看android:layout_toLeftOf。我相信您需要将其添加到溢出的文本视图中并将其设置为等于您的按钮视图。您希望 TextView 位于按钮的左侧。

      【讨论】:

        猜你喜欢
        • 2014-12-30
        • 2020-12-31
        • 2013-10-08
        • 1970-01-01
        • 1970-01-01
        • 2015-07-01
        • 2018-09-21
        • 1970-01-01
        • 2015-02-07
        相关资源
        最近更新 更多