【发布时间】:2015-08-19 00:58:27
【问题描述】:
我正在尝试将我的 actionbar 设计为在 actionbar 的死点有 textview,以及一个 imageview 在 actionbar 的最右侧,但我无法让图像一直对齐。
无论我更改什么不同的属性,图像都会将我的 textview 向左推,并且会在 imageview 的右侧留下大量空间。
这是 action_bar 自定义 XML 布局,它在我的活动中被夸大了。
[![
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:weightSum="3"
>
<ImageButton android:src="@drawable/users"
android:background="?attr/actionBarItemBackground"
android:layout_width="24dp"
android:layout_height="24dp"
android:scaleType="centerInside"
android:id="@+id/item2"
android:layout_alignParentRight="true"
android:layout_alignParentTop="false"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Location"
android:id="@+id/textView2"
android:layout_gravity="center_horizontal"
android:textStyle="bold"
android:textColor="#ffffff"
android:layout_centerHorizontal="true" />
</RelativeLayout>
这是正在发生的事情的一个例子
【问题讨论】: