0

タイトルで ellipsize を機能させようとしましたが、画像でわかるように、2 つの追加された画像ボタンの前ではなく、メニュー ボタンの前に ... を設定しました。

タイトルを設定するアクティビティ コード:

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