Android light theme with action bar -
i want use light theme, still have actionbar visible.
from here looks should work:
<activity android:theme="@style/theme.appcompat.light" ... >
but when add android:theme actionbar disappears.
i'm missing obvious...
edit: in case helps
from build.gradle
apply plugin: 'com.android.application' android { compilesdkversion 21 buildtoolsversion "21.1.2" defaultconfig { applicationid "com.company.app" minsdkversion 15 targetsdkversion 21 versioncode 5 versionname "1.0" } buildtypes { release { minifyenabled true proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile filetree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.0.0' }
activity_main.xml:
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/screen_main" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" tools:context=".owg"> <textview android:id="@+id/textheader" android:textsize="24sp" android:textcolor="#006699" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" android:visibility="visible" /> <listview android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <textview android:id="@android:id/empty" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="empty set" android:visibility="invisible" /> </linearlayout>
main.java
package com.company.app; import android.app.alertdialog; import android.app.listactivity; import android.os.bundle; import android.widget.listview; import android.content.intent; import android.view.view; public class main extends listactivity { private string[] mbooks = new string[]{ "informational", "extensions" }; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); mysimplearrayadapter booksadapter = new mysimplearrayadapter(this,mbooks); listview lv = (listview) findviewbyid(android.r.id.list); lv.setadapter(booksadapter); } }
use this:
<activity android:theme="@style/theme.appcompat.light.darkactionbar" ... >
instead of :
<activity android:theme="@style/theme.appcompat.light" ... >
it should work. issue here, use style without actionbar now, , there choices how action bar look(see related styles)
//use fill action bar items @override public boolean oncreateoptionsmenu(menu menu) { menuinflater inflater = getmenuinflater(); inflater.inflate(r.menu.your_menu_name, menu); return true; }
or if yout want custom view actionbar
//getting action bar mactionbar = getactionbar();
and use
mactionbar.setcustomview(mcustomview);//view object actionbar mactionbar.setdisplayshowcustomenabled(true)
edit: if can't see title bar can create programmatically
requestwindowfeature(window.feature_custom_title); setcontentview(r.layout.settings); activity.settitle("settings");
Comments
Post a Comment