我設置了自定義標題佈局,無法看到操作欄的三個橫條。我在沒有硬件菜單按鈕的三星筆記10.1上使用這個應用程序。我的父母是android:主題,所以我不知道爲什麼操作欄是隱藏的。目標版本「16 MINVERSION是 「14」未在自定義標題中顯示的操作欄
這裏是清單文件設置與自定義主題。
<application
android:allowBackup="true"
android:icon="@drawable/logo_icon"
android:label="@string/app_name"
android:theme="@style/CustomTheme">
這是添加項目custom_title.xml。
<resources>
<style name="CustomWindowTitleBackground">
<item name="android:background">#323331</item>
</style>
<style name="CustomTheme" parent="android:Theme">
<item name="android:windowTitleSize">45dip</item>
<item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
</style>
這是組成自定義標題的title.xml
<?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:orientation="horizontal" >
<ImageView
android:id="@+id/image_icon"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="7dp"
android:src="@drawable/logo_icon" />
<TextView
android:id="@+id/Application"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text=" ColorMaker Simple RGB "
android:textSize="20dp" />
<!-- Bluetooth info -->
<TextView
android:id="@+id/textbluetooth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="BlueTooth: "
android:textSize="20dp" />
<ImageView
android:id="@+id/image_bt_on_off"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_gravity="center_vertical"
android:background="@drawable/circle" />
<!-- Network info -->
<TextView
android:id="@+id/textspacer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text=" | "
android:textSize="20dp" />
<TextView
android:id="@+id/textnetwork"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="Network : "
android:textSize="20dp" />
<TextView
android:id="@+id/textspacer1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text=" | "
android:textSize="20dp" />
<!-- Fade info -->
<TextView
android:id="@+id/textfade_on_off"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="Fade : "
android:textSize="20dp" />
<TextView
android:id="@+id/textspacer2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text=" | "
android:textSize="20dp" />
菜單項
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.simple_rgb__main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.title:
startActivity(new Intent(this, Prefrences.class));
// Activity2.this.startActivity(myIntent);
break;
}
return true;
}
記錄錯誤
11-24 17:47:54.593: D/AndroidRuntime(6607): Shutting down VM
11-24 17:47:54.593: W/dalvikvm(6607): threadid=1: thread exiting with uncaught exception (group=0x40d0f2a0)
11-24 17:47:54.601: E/AndroidRuntime(6607): FATAL EXCEPTION: main
11-24 17:47:54.601: E/AndroidRuntime(6607): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.simplergb/com.example.simplergb.SimpleRGB_Main}: android.util.AndroidRuntimeException: You cannot combine custom titles with other title features
11-24 17:47:54.601: E/AndroidRuntime(6607): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2129)
11-24 17:47:54.601: E/AndroidRuntime(6607): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2154)
11-24 17:47:54.601: E/AndroidRuntime(6607): at android.app.ActivityThread.access$700(ActivityThread.java:146)
11-24 17:47:54.601: E/AndroidRuntime(6607): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1260)
11-24 17:47:54.601: E/AndroidRuntime(6607): at android.os.Handler.dispatchMessage(Handler.java:99)
11-24 17:47:54.601: E/AndroidRuntime(6607): at android.os.Looper.loop(Looper.java:137)
11-24 17:47:54.601: E/AndroidRuntime(6607): at android.app.ActivityThread.main(ActivityThread.java:4949)
11-24 17:47:54.601: E/AndroidRuntime(6607): at java.lang.reflect.Method.invokeNative(Native Method)
11-24 17:47:54.601: E/AndroidRuntime(6607): at java.lang.reflect.Method.invoke(Method.java:511)
11-24 17:47:54.601: E/AndroidRuntime(6607): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1043)
11-24 17:47:54.601: E/AndroidRuntime(6607): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)
11-24 17:47:54.601: E/AndroidRuntime(6607): at dalvik.system.NativeStart.main(Native Method)
11-24 17:47:54.601: E/AndroidRuntime(6607): Caused by: android.util.AndroidRuntimeException: You cannot combine custom titles with other title features
11-24 17:47:54.601: E/AndroidRuntime(6607): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:289)
11-24 17:47:54.601: E/AndroidRuntime(6607): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:3118)
11-24 17:47:54.601: E/AndroidRuntime(6607): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3358)
11-24 17:47:54.601: E/AndroidRuntime(6607): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:314)
11-24 17:47:54.601: E/AndroidRuntime(6607): at android.app.Activity.setContentView(Activity.java:1920)
11-24 17:47:54.601: E/AndroidRuntime(6607): at com.example.simplergb.SimpleRGB_Main.onCreate(SimpleRGB_Main.java:169)
11-24 17:47:54.601: E/AndroidRuntime(6607): at android.app.Activity.performCreate(Activity.java:5185)
11-24 17:47:54.601: E/AndroidRuntime(6607): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
11-24 17:47:54.601: E/AndroidRuntime(6607): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2093)
11-24 17:47:54.601: E/AndroidRuntime(6607): ... 11 more
澄清,是整個行動吧失蹤,或只是你的自定義樣式? – Jonik
自定義樣式已應用,但缺少3點動作條。 title.xml中的所有信息都很好。 – Bobby