0

我试图让 ellipsize 来处理我的标题,但正如您在图像中看到的那样,它在菜单按钮之前设置了 ...,而不是在添加的两个图像按钮之前。

设置标题的活动代码:

// set title
TextView mTitle = (TextView)findViewById(R.id.group_post_title);
mTitle.setText(title);

标题 XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/group_post_title"
        style="@style/title"
        android:text="@string/group_post" />

    <ImageButton
        android:id="@+id/group_post_comment_add"
        android:layout_width="40dp"
        android:layout_height="match_parent"
        android:layout_centerVertical="true"
        android:layout_toLeftOf="@+id/group_post_status_view"
        android:background="@drawable/title_button"
        android:contentDescription="@string/add_grouppost"
        android:src="@android:drawable/ic_menu_add" />

    <RelativeLayout
        android:id="@+id/group_post_status_view"
        android:layout_width="40dp"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:orientation="horizontal" >

        <ProgressBar
            android:id="@+id/group_post_status"
            style="?android:attr/progressBarStyleSmall"
            android:layout_width="40dp"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:visibility="gone" />

        <ImageButton
            android:id="@+id/group_post_reload"
            android:layout_width="40dp"
            android:layout_height="match_parent"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:background="@drawable/title_button"
            android:contentDescription="@string/reload"
            android:src="@drawable/menu_refresh" />
    </RelativeLayout>

</RelativeLayout>

款式代码:

<style name="title">
      <item name="android:singleLine">true</item>
      <item name="android:ellipsize">end</item>
      <item name="android:scrollHorizontally">true</item>
      <item name="android:layout_centerVertical">true</item>
      <item name="android:layout_marginLeft">5dp</item>
      <item name="android:textSize">16sp</item>
      <item name="android:layout_width">fill_parent</item>
      <item name="android:layout_height">wrap_content</item>
</style>

图片:http: //i.imgur.com/oOGns2L.png

4

1 回答 1

0

我找到了解决方案:

LinearLayout在右侧的“事物”周围添加一个。给它一个id. 使用android:layout_toLeftOfTextViewidLinearyLayout的标题和 wupti 标题使用android:ellipsize正确。

于 2013-08-28T13:35:40.873 回答