<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/actionbar_color"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="?android:attr/actionBarSize"
android:orientation="horizontal">
<ImageView
android:id="@+id/imgActionLeftIcon"
android:layout_width="?android:attr/actionBarSize"
android:layout_height="match_parent"
android:layout_margin="@dimen/action_btn_margine"
android:src="@drawable/menu_logo" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="@+id/txtActionTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center"
android:maxLines="1"
android:ellipsize="end"
android:text="Medium Text ghjhjgjkghdfggh"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<ImageView
android:layout_width="@dimen/action_btn_height_width"
android:layout_height="match_parent"
android:padding="@dimen/_2sdp"
android:src="@mipmap/ic_launcher" />
</LinearLayout>
<ImageView
android:id="@+id/imgActionRightIcon"
android:layout_width="?android:attr/actionBarSize"
android:layout_height="match_parent"
android:layout_margin="@dimen/action_btn_margine"
android:src="@drawable/menu_logo" />
</LinearLayout>
答案 0 :(得分:1)
解决了这个问题。查看我的代码(添加属性layout_weight
):
<TextView
android:id="@+id/txtActionTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:gravity="center"
android:maxLines="1"
android:ellipsize="end"
android:text="Medium Text ghjhjgjkghdfggh"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF"
android:textStyle="bold" />