中心操作栏自定义

时间:2013-12-20 20:21:41

标签: android android-actionbar

我在操作栏中放置了自定义视图

<?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" >

<ImageView
    android:id="@+id/icon"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:src="@drawable/internal_header_logo_gasbuddy" />   
</RelativeLayout>

// here is a snip of tha runtime
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
getActionBar().setTitle("");

getActionBar().setDisplayShowCustomEnabled(true);
LayoutInflater inflator = (LayoutInflater) this
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflator.inflate(R.layout.custombar, null);
getActionBar().setCustomView(v);

这几乎可以满足我的需求。 图形位于NavDrawerIcon,Programicom,title,customview,settingsicon之间操作栏的中心区域中心

我希望新视图以整个显示的宽度为中心,因此它不会像其他ab元素那样移动

非常感谢帮助

0 个答案:

没有答案
相关问题