Android 安卓操作栏没有';不显示
我已经为android应用程序设置了一个自定义操作栏。它有两个按钮(左和右)和标题(中间) 但是我不明白为什么它没有出现。(我有一条白色的小带子) 这是我的自定义布局Android 安卓操作栏没有';不显示,android,android-actionbar,Android,Android Actionbar,我已经为android应用程序设置了一个自定义操作栏。它有两个按钮(左和右)和标题(中间) 但是我不明白为什么它没有出现。(我有一条白色的小带子) 这是我的自定义布局 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:layout_centerVertical="true"
android:background="@color/oeo_grey_4"
>
<ImageView
android:id="@+id/actionbar_menu_button"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:clickable="false"
android:focusable="false"
android:longClickable="false"
android:src="@drawable/actionbar_menu_button"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
/>
<TextView
android:id="@+id/actionbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TITLE"
android:gravity="center"
android:textSize="18sp"
android:singleLine="true"
android:ellipsize="end"
android:textColor="@color/oeo_grey_2"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
/>
<ImageView
android:id="@+id/actionbar_account_button"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:clickable="false"
android:focusable="false"
android:longClickable="false"
android:src="@drawable/actionbar_account_button"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
/>
</RelativeLayout>
谢谢 在MainActivity.java$OnCreate中尝试
getActionBar().show();
在您的styles.xml中
<style name="HoloLight" parent="android:Theme.Holo.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
在你的清单中
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/HoloLight">
您错误地使用以下命令设置了自定义视图:
actionBar.setCustomView(R.layout.actionBar\u菜单\u按钮)代码>
您可以充气
自定义视图:
LayoutInflater mInflater = LayoutInflater.from(this);
View mCustomView = mInflater.inflate(R.layout.custom_actionbar, null);
mActionBar.setCustomView(mCustomView);
mActionBar.setDisplayShowCustomEnabled(true);
查看更多信息
LayoutInflater mInflater = LayoutInflater.from(this);
View mCustomView = mInflater.inflate(R.layout.custom_actionbar, null);
mActionBar.setCustomView(mCustomView);
mActionBar.setDisplayShowCustomEnabled(true);