How do you remove the title text from the Android ActionBar?
Try: getActionBar().setDisplayShowTitleEnabled(false); For v.7: getSupportActionBar().setDisplayShowTitleEnabled(false);
Try: getActionBar().setDisplayShowTitleEnabled(false); For v.7: getSupportActionBar().setDisplayShowTitleEnabled(false);
You can with a style, but you have to add it to the main Theme declaration. <resources> <!– Base application theme. –> <style name=”Your.Theme” parent=”@android:style/Theme.Holo”> <!– Pointer to Overflow style ***MUST*** go here or it will not work –> <item name=”android:actionOverflowButtonStyle”>@style/OverFlow</item> </style> <!– Styles –> <style name=”OverFlow” parent=”@android:style/Widget.Holo.ActionButton.Overflow”> <item name=”android:src”>@drawable/ic_action_overflow</item> </style> </resources> You also can … Read more
EDIT: make sure you set this drawable as LOGO, not as your app icon like some of the commenters did. Just make an XML drawable and put it in the resource folder “drawable” (without any density or other configuration). <?xml version=”1.0″ encoding=”utf-8″?> <layer-list xmlns:android=”http://schemas.android.com/apk/res/android” > <item android:drawable=”@drawable/my_logo” android:right=”10dp”/> </layer-list> The last step is to set … Read more
Expand the SearchView with searchView.setIconified(false); and collapse it with searchView.setIconified(true); You need to change the value of android:showAsAction from ifRoom|collapseActionView to always. The SearchView‘s attribute android:iconifiedByDefault should be true, which is the default value, otherwise the user can not collapse the SearchView after it was expanded programmatically.
The ActionBar will use the android:logo attribute of your manifest, if one is provided. That lets you use separate drawable resources for the icon (Launcher) and the logo (ActionBar, among other things).
Please find the GitHub Repo: Here A bit late to the party, but this is my solution that I am using as a work around continuing to use PreferenceActivity: settings_toolbar.xml : <?xml version=”1.0″ encoding=”utf-8″?> <android.support.v7.widget.Toolbar xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” android:id=”@+id/toolbar” app:theme=”@style/ThemeOverlay.AppCompat.Dark.ActionBar” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:minHeight=”?attr/actionBarSize” app:navigationContentDescription=”@string/abc_action_bar_up_description” android:background=”?attr/colorPrimary” app:navigationIcon=”?attr/homeAsUpIndicator” app:title=”@string/action_settings” /> SettingsActivity.java : public class SettingsActivity extends PreferenceActivity { … Read more
You need to cast your activity from getActivity() to AppCompatActivity first. Here’s an example: ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(); The reason you have to cast it is because getActivity() returns a FragmentActivity and you need an AppCompatActivity In Kotlin: (activity as AppCompatActivity).supportActionBar?.title = “My Title”
In fact, there’s a way to do this. Even without implementing your own ActionBar. Just have a look at the hierachyviewer! (Located in the tools directory) There’s the DecorView, and a LinearLayout as a child. This LinearLayout contains both the ActionBar and the other content. So, you can simply apply some FrameLayout.LayoutParams to this LinearLayout … Read more
Nothing helped, but changing: ?attr/actionBarSize to ?android:attr/actionBarSize did the job. That’s actually a bug in few versions. Even if you won’t fix it, Android will automatically fix it at runtime.
ActionBar is deprecated ever since Toolbar was introduced. Toolbar can be seen as a ‘superset’ of any action bar. So the ‘old’ ActionBar is now an example of a Toolbar. If you want similar functionality, but without deprecation warnings do the following: Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { toolbar.setTitle(R.string.app_name); setSupportActionBar(toolbar); } … Read more