Split Action Bar not working - android

i have been looking for solutions for hours. i'm trying to split my action bar but it keeps stacking up in the top-right corner.
this is my menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:balloonberry="http://schemas.android.com/apk/res-auto">
<item android:id="#+id/action_search"
android:icon="#drawable/ic_action_search"
android:title="#string/action_search"
balloonberry:showAsAction="always"/>
<item android:id="#+id/action_location_found"
android:icon="#drawable/ic_action_location_found"
android:title="#string/action_location_found"
balloonberry:showAsAction="always"/>
<item android:id="#+id/action_refresh"
android:icon="#drawable/ic_action_refresh"
android:title="#string/action_refresh"
balloonberry:showAsAction="always"/>
<item android:id="#+id/action_help"
android:icon="#drawable/ic_action_help"
android:title="#string/action_help"
balloonberry:showAsAction="always"/>
<item android:id="#+id/action_check_updates"
android:icon="#drawable/ic_action_refresh"
android:title="#string/action_check_updates"
balloonberry:showAsAction="always"/>
</menu>
this is my AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zapp.exampleproject1" >
<uses-sdk android:minSdkVersion="17"></uses-sdk>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat.Light"
android:uiOptions="splitActionBarWhenNarrow">
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="android.support.UI_OPTIONS"
android:value="splitActionBarWhenNarrow`" />
</activity>
</application>
</manifest>
any solutions???? (i'm using a android 4.3 phone)

Neither appcompat-v7, nor the native action bar on Android 5.0+, support the split action bar. That pattern was officially discontinued as part of the Material Design overhaul. If you want that capability, you will need to put your own Toolbar at the bottom of your activity.

Related

How to add a split ActionBar in android.I have got everything right but it still doesn't work.

here is my code
MainActivity
public class MainActivity extends ActionBarActivity{
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
}
menu_main.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
<item android:id="#+id/action_settings" android:title="#string/action_settings"
android:orderInCategory="100" app:showAsAction="never" />
<item android:id="#+id/one" android:title="oneone"
android:orderInCategory="100" app:showAsAction="always" />
<item android:id="#+id/two" android:title="twotwo"
android:orderInCategory="100" app:showAsAction="ifRoom" />
<item android:id="#+id/three" android:title="threethree"
android:orderInCategory="100" app:showAsAction="ifRoom" />
<item android:id="#+id/four" android:title="fourfour"
android:orderInCategory="100" app:showAsAction="ifRoom" />
</menu>
manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sanjith.actionbartwo" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
>
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
This code gives me three buttons on the actionbar and one on the overflow.
I want to get all the buttons on the bottom actionbar.I have searched the internet for this but i haven't found a solution.
Please help.
Try this http://developer.android.com/guide/topics/ui/actionbar.html#SplitBar
<manifest ...>
<activity uiOptions="splitActionBarWhenNarrow" ... >
<meta-data android:name="android.support.UI_OPTIONS"
android:value="splitActionBarWhenNarrow" />
</activity>
</manifest>
I have encountered this problem before unfortunately the action bar doesn't split by code you need to fill all the room available so the action bar would split by itself with your permission of course but there are no possible way to split it if it still have space

Android - ActionBar icon not showhing

I have trouble seeing the icons in the ActionBar.
I also read around here in StackOverFlow, but nothing...
Here is my action.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" >
<item
android:id="#+id/addAct"
android:icon="#android:drawable/ic_input_add"
android:background="#null"
app:showAsAction="always"
android:title="#string/add"
/>
<item
android:id="#+id/searchAct"
android:icon="#android:drawable/ic_menu_search"
app:showAsAction="ifRoom"
android:title="Cerca"
android:actionViewClass="android.widget.SearchView"
/>
<item
android:id="#+id/visualizza"
android:title="#string/txtVisualizza"
app:showAsAction="always"
>
</item>
Here, is AndroiManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<uses-sdk
android:minSdkVersion="11"
android:maxSdkVersion="21"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".WriteActivity"
android:label="#string/title_activity_write" >
</activity>
</application>
Here, MainActivity:
public class MainActivity extends Activity { ...
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.action, menu);
return super.onCreateOptionsMenu(menu);
}
In the xml code, I have used the app for ShowAsAction, but this not seems be the problem.
Thanks for any help :)
You are developing app for material design ( Target SDK = 21).
It does not support Activity.
So change extends Activity to extends ActionBarActivity.
Now your menu will be visible.
And you can edit action bar using getSupportActionBar().

Actions Buttons in Android not visible

I'm currently working on my first android app following the official tutorial.
Right now im trying to add Action Buttons to my
MainActivity:
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu items for use in the action bar
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_activity_actions, menu);
return super.onCreateOptionsMenu(menu);
}
res/menu/main_activity_actions.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Search, should appear as action button -->
<item android:id="#+id/action_search"
android:icon="#drawable/ic_action_search"
android:title="#string/action_search"
android:showAsAction="ifRoom" />
<!-- Settings, should always be in the overflow -->
<item android:id="#+id/action_settings"
android:title="#string/action_settings"
android:showAsAction="never" />
</menu>
The application is running without any errors, but the search button is not displayed. ic_action_search icon is properly placed into res/drawable-* and action_search/action_settings is defined in strings.xml.
Am I missing something?
Edit:
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.myfirstapp.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.myfirstapp.DisplayMessageActivity"
android:label="#string/title_activity_display_message"
android:parentActivityName="com.example.myfirstapp.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.myfirstapp.MainActivity" />
</activity>
</application>
</manifest>
styles.xml
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.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 theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
As per the document
If your app is using the Support Library for compatibility on versions as low as Android 2.1, the showAsAction attribute is not available from the android: namespace. Instead this attribute is provided by the Support Library and you must define your own XML namespace and use that namespace as the attribute prefix. (A custom XML namespace should be based on your app name, but it can be any name you want and is only accessible within the scope of the file in which you declare it.) For example:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:yourapp="http://schemas.android.com/apk/res-auto" >
<item android:id="#+id/action_search"
android:icon="#drawable/ic_action_search"
android:title="#string/action_search"
yourapp:showAsAction="ifRoom" />
...
</menu>
You are missing custom namespace in the main_activity_actions.xml. Remove yourapp with the name of app or anything.

custom action bar keeps disappearing when i switch between fragments using the navDrawer

I wanted to add my own custom action bar to the drawer navigation by Google which i have figured out, the problem is, that when I try to open the drawer the Action bar then disappears, along with the icon that allows me to toggle the drawer is also gone for good. it again disappears when i click on my next fragment activity. I also noticed that if i leave the theme of the app back to its default theme everything works fine.
here's my custom theme style class
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:background">#f0f0</item>
</style>
</resources>
manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.navigationdrawerexample"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="17" />
<application
android:label="#string/app_name"
android:icon="#drawable/ic_launcher"
android:theme="#android:style/Theme.Holo.Light.DarkActionBar">
<activity
android:name=".MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
When it works i use #android:style/Theme.Holo.Light.DarkActionBar for the theme

custom themes didn't effect on buttons

I have themes file to apply all of my buttons. The following coding is in my themes file.
<style name="CustomButton" parent="#android:style/Widget.Holo.Light.Button">
<item name="android:textSize">14sp</item>
<item name="android:layout_width">72dp</item>
<item name="android:layout_height">32dp</item>
<item name="android:background">#drawable/button_selector</item>
</style>
<style name="MyTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:buttonStyle">#style/CustomButton</item>
</style>
In the #drawable/button_selector
<selector>
<item android:drawable="#drawable/btn_bg">
<shape>
<size android:width="72dip" android:height="32dip"/>
<stroke
android:width="1dp"
android:color="#992f2f" />
<corners
android:radius="3dp" />
</shape>
</item>
</selector>
In my layout file
<Button android:id="#+id/savebtn"
android:layout_width="wrap_content" android:layout_marginRight="15dip"
android:layout_height="wrap_content"
android:text="Save"/>
My problem is that the button width and height didn't change. When I set layout_with(72dp) and layout_height(32dp) in the savebtn directly, it works. I have already defined themes file in application tag. I don't want to set all of my buttons like that. I would like to know any suggestions or idea?
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myproject"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="15" />
<application
android:label="#string/app_name"
android:theme="#style/MyTheme">
<activity
android:name=".activity.setting.SettingActivity"
android:label="#string/menu_settings" >
</activity>
<activity
android:name=".activity.setting.AboutActivity"
android:label="#string/app_name" >
</activity>
<activity
android:name=".activity.DetailsActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I tested exactly your code and it worked.
Did you add the following on your AndroidManifest.xml?
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/MyTheme" >
If still doesn't work, please post your manifest!
Also pay attention that if you are setting another theme on your activity, it will override the application theme!

Categories

Resources