我怎么能让一个操作栏在中心有徽标,两边有两个动作项?

我将使用ActionBar Sherlock.
我想在动作栏右侧添加图像视图.我试图这样做,但我不能.谁能帮我?
这是我的图像视图xml
<ImageView
android:id="@+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/adnace_search_i" />
Run Code Online (Sandbox Code Playgroud)
这是我想要创建的动作栏的图像.

尝试为我的操作栏设置自定义视图,但问题是它没有填满操作栏的整个宽度,这使得我可以使对象居中.如何在我的操作栏中设置自定义视图以填满整个操作栏?
设置我的操作栏的代码:
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setDisplayShowTitleEnabled(false);
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
actionBar.setCustomView(inflater.inflate(R.layout.actionbar_layout, null));
Run Code Online (Sandbox Code Playgroud)
还有我的actionbar_layout.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="wrap_content"
android:layout_gravity="center"
android:background="#EDEDED">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/title"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textColor="#FFFFFF"
android:text="Testing"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) 如何使用XML主题更改操作栏图标或徽标空间的顶部和底部填充或边距?
<style name="Theme.Whycheck" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarItemBackground">@drawable/selectable_background_whycheck</item>
<item name="actionBarStyle">@style/ActionBar.Solid.Whycheck</item>
<item name="actionModeBackground">@drawable/cab_background_top_whycheck</item>
<item name="actionModeSplitBackground">@drawable/cab_background_bottom_whycheck</item>
<!-- Light.DarkActionBar specific -->
<item name="actionBarWidgetTheme">@style/Theme.Whycheck.Widget</item>
</style>
<style name="ActionBar.Solid.Whycheck" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">@drawable/ab_solid_whycheck</item>
<item name="backgroundStacked">@drawable/ab_stacked_solid_whycheck</item>
<item name="backgroundSplit">@drawable/ab_bottom_solid_whycheck</item>
</style>
<style name="ActionBar.Transparent.Whycheck" parent="@style/Widget.AppCompat.ActionBar">
<item name="background">@drawable/ab_transparent_whycheck</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Whycheck.Widget" parent="@style/Theme.AppCompat">
</style>
Run Code Online (Sandbox Code Playgroud)
提供我的风格.
我想显示一个带有自定义布局的Action Bar.自定义布局有三个ImageView,一个位于中心,另外两个位于操作栏的左右两端.必须没有后退按钮或操作项.
这是我用过的:
android.support.v7.app.ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
ActionBar.LayoutParams lp = new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT);
View actionBarView = LayoutInflater.from(this).inflate(resource, null);
actionBar.setCustomView(actionBarView, lp);
Run Code Online (Sandbox Code Playgroud)
自定义布局正确充气,但不占据屏幕的整个宽度.这发生在Android 4.4.2(KitKat)上.在Gingerbread上,上述安排正常.
我在以下讨论中尝试了推荐的解决方案:
但问题仍然存在.必须有一种方法来强制布局占据整个屏幕宽度.
我正在使用V7 AppCompat库中的Action Bar.有没有人知道这个方法?
编辑1:
这是XML布局文件:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_horizontal"
android:orientation="horizontal">
<ImageView
android:id="@+id/left_icon"
android:background="@drawable/leftbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:scaleType="centerInside"
android:clickable="true"
android:onClick="leftButtonPressed"
android:hapticFeedbackEnabled="true"
/>
<ImageView
android:id="@+id/center_icon"
android:background="@drawable/centertitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:adjustViewBounds="true"
android:scaleType="centerInside"
/>
<ImageView
android:id="@+id/right_icon"
android:background="@drawable/rightbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:scaleType="centerInside"
android:clickable="true" …Run Code Online (Sandbox Code Playgroud) 我要自定义我的操作栏。我想在操作栏中添加一个ImageButton,单击该按钮将转到另一个活动。我的代码如下。我不知道继续前进。谁能建议我一步一步去做。
final ActionBar actionBar = getActionBar();
actionBar.setBackgroundDrawable(getResources().getDrawable(R.color.blue));
Run Code Online (Sandbox Code Playgroud)