android-actionbar

Stacked ActionBar Tab with Custom View Not Displaying Properly

我的梦境 提交于 2019-12-19 22:07:56
问题 When using action bar tabs, sometimes they are displayed as "stacked" when tab content is too large for the display. A problem arises when I use a custom view for the tab content, it causes the selected tab to not be displayed in the dropdown, and once a tab is selected, the dropdown goes away, and small, empty tabs appear. Here is a screenshot of the dropdown, before selecting an item: (note that the content of the tab is not displayed, even when the tab is selected) Also, after selecting

How to set a SearchView's input type to numeric

拜拜、爱过 提交于 2019-12-19 13:09:31
问题 I currently have a SearchView in my app's ActionBar (of which I am populating from an XML layout file) and I am trying to force it to only take numeric input. I've tried setting the android:inputType="number" attribute in XML, but it has no effect. Does anyone know the source of this problem? The XML menu resource: <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/search" android:title="@string/menu_search" android:actionViewClass="android.widget

Android Toolbar instead of action bar

我是研究僧i 提交于 2019-12-19 10:29:27
问题 I'm trying to use Toolbar instead of ActionBar. In Android 5.0.+ it works but in 4.4 the status bar is placed on top of the Toolbar. Screenshot: Layout: <android.support.v7.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="?attr/actionBarSize" app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" android

How to set the Toolbar collapseIcon color programmatically

*爱你&永不变心* 提交于 2019-12-19 09:06:09
问题 I want to change the color of the back button in the toolbar when a search is displayed (the circled white arrow). I managed to change the color of all other elements and I am stuck with the back arrow color. I can set the collapseIcon (back arrow drawable) from xml: <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:layout_scrollFlags="enterAlways" app

Intermediate Progress doesn't work with ActionBarSherlock running on Gingerbread

可紊 提交于 2019-12-19 07:58:10
问题 I setup ActionBarSherlock with my app, and I'm trying to use the Intermediate Progress, I'm using this: requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setSupportProgressBarIndeterminateVisibility(false); In my onCreate, and then using: setSupportProgressBarIndeterminateVisibility(true); To enable it. It works fine in ICS but it doesn't work at all in Gingerbread or Froyo, does anyone know how to get it to work? Thanks 回答1: I just had the same problem. Jake's solution above did

How to change programmatically background color of action bar items

可紊 提交于 2019-12-19 07:09:26
问题 It is easy to set a default color of the items background in action bar by setting: <item name="android:actionBarItemBackground">@drawable/action_bar_item_background</item> in application theme. I would like to change this color only for one of my fragments. How to do it programmatically? 回答1: Have you tried the solution from user3225831 mentioned here: https://stackoverflow.com/a/21297231/1738838 ActionBar bar = getActionBar(); bar.setBackgroundDrawable(new ColorDrawable("COLOR")); 回答2: Use

How can I add my spinner to the ActionBar?

别等时光非礼了梦想. 提交于 2019-12-19 05:23:29
问题 I'm trying to get my spinner working as the Action Bar Drop Down List item, but I cant seem to implement it at all, there aren't many tutorials for this after searching through Google. I think its something to do with the .setListNavigationCallbacks(); line of code, I just have no idea how to get this working from that line onwards. // setup action bar for spinner ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); bar.setListNavigationCallbacks(); Spinner

How to set bold title in Action Bar?

家住魔仙堡 提交于 2019-12-19 05:23:19
问题 I am editing the style xml trying to get the Activity title bold. <style name="MyTheme" parent="@android:style/Theme.Holo.Light"> <item name="android:actionBarStyle">@style/MyActionBar</item> </style> <style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar"> <item name="android:background">#81CFEB</item> <item name="android:textStyle">bold</item> </style> But only what I can set is the background color desired. I do not why the textStyle is not set to bold. Anyone know

How to dismiss/close/collapse SearchView in ActionBar in MainActivity?

拈花ヽ惹草 提交于 2019-12-19 05:04:24
问题 I'm trying to clear and close SearchView after entering a value. I found a solution but it closes the search and won't perform any action if I try to search again. @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main_actions, menu); searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); searchView.setOnQueryTextListener(searchListener); return super.onCreateOptionsMenu(menu); } SearchView.OnQueryTextListener

Changing android actionbar button style

早过忘川 提交于 2019-12-19 04:56:18
问题 I'm currently changing the view on my ActionBar MenuItem like so: MenuItem menuItem = menu.add(title); TextView tv = new TextView(context); tv.setTypeface(myTypeface); tv.setText("hello"); menuItem.setActionView(tv); However this disabled the function of the button, which I'm assuming is because I've changed the ActionView . Is there anyway I can do this whilst retaining the button function? 回答1: Here's an example of creating a custom MenuItem for the ActionBar . First : Create the View that