android-toolbar

Show toolbar when view pager is swiped. [CoordinatorLayout]

坚强是说给别人听的谎言 提交于 2019-12-02 02:15:29
问题 in my app I am using a viewpager with 3 fragments. In two of those I have recuclerviews. I took advatngage of the new Coordinator layout and made my toolbar hides/shows when scrolling on a recyclerview. My problem is the following Say the user is scrolling on a recyclerview list in fragment A and thus the toolbar is hidden. After that, the user performs a swipe and goes to fragment B which does not have a recycle view to scroll so the toolbar can appear again. Is there a way I can alter the

Android - How to center a title (TextView) in a toolbar?

只谈情不闲聊 提交于 2019-12-01 23:02:15
On the left of my toolbar I have a logo, and I want to center a TextView in the same toolbar to act as my title. For some reason, the title does not center, and is instead on the right. Here is my attempt: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".Register"> <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app=

Android Toolbar menu text color

蓝咒 提交于 2019-12-01 17:38:46
问题 I'm trying to change my Toolbar's menu item text color here, but it doesn't work. Here's my style: <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="toolbarStyle">@style/AppTheme.ToolbarStyle</item> <item name="buttonStyle">@style/AppTheme.ButtonStyle</item> <item name="colorControlHighlight">@color

Correct way to change Collapseable Toolbar title

坚强是说给别人听的谎言 提交于 2019-12-01 15:53:18
问题 When I change title of collapsed collapsingToolbar, the title doesn't change. I've tried getSupportActionBar.setTitle and collapseToolbar.setTitle, but it didn't help. Tell me, what's the problem ? 回答1: I believe that this issue describes what you are experiencing. I also had this issue and solved it today. Essentially the code that handles the collapsing text only update the text when the current text is null or the size of the text changes. Currently this is a bug that is closed and the

How to center&left&right align the ActionBar icons in Android

泄露秘密 提交于 2019-12-01 14:45:12
问题 hi there I want align a set of icons in toolbar like below picture. I googled and after some change I have: mainActivity.xml ... <include android:id="@+id/tool_bar_bottom" layout="@layout/tool_bar" android:layout_height="wrap_content" android:layout_width="fill_parent" /> .... And in menu_bottom.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">

How to set an icon at the end of Toolbar

血红的双手。 提交于 2019-12-01 13:59:02
问题 I want to set an icon at the the end of my Toolbar ,which start another activity. My Toolbar portion <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" android:layout_width="match_parent" android:layout_height="@dimen/abc_action_bar_default_height_material" android:background="#2B4AE0" app:theme="@style/ToolBarStyle"> <TextView android:id="@+id/headerText" android:layout

Set Toolbar Icon Colour Programmatically

大兔子大兔子 提交于 2019-12-01 09:29:01
How can I set the colour of icons (home and overflow menu icon) in a Toolbar / AppBarLayout programmatically ? I want to change the toolbar's colour scheme for a single fragment in an activity. Setting the AppBarLayout 's background to a light colour (e.g. light gray with appBarLayout.setBackgroundResource(..); ) results in white icons and a white title which are barely visible. Its layout is as follows: <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:fitsSystemWindows="true"> <android.support

How to change toolbar menu item text color for pre Lollipop and Lollipop versions

六眼飞鱼酱① 提交于 2019-12-01 08:51:58
问题 I am using Toolbar for the purpose of material design in my application. Everything working fine but except when it comes to change the menu item text color I am completely stuck up with the solution. I am also posting screenshot of the text that should be taken and code I am using in my application for your reference. I tried several alternate methods like assigning as follows <item name="android:actionMenuTextColor">@color/white</item> <item name="android:textColor">#000</item> But known of

Ripple effect on Toolbar cut off

徘徊边缘 提交于 2019-12-01 06:29:35
I'm using a Toolbar in my app and am inflating it with a menu. I have a issue here because the ripple effect is automatically added to the button but the left most button's ripple effect is cut off by the boundary of the menu area. You can see the ripple expand but it is then but off on the left side. Any idea how to remedy this issue? I came across this too, after playing around I found our custom ThemeOverlay had its background set. Try removing android:background from your Toolbar style and theme. See below I commented out: <item name="android:background">@color/toolbar</item> . It works as

Error inflating class android.support.v7.widget.Toolbar

孤人 提交于 2019-12-01 05:59:07
I have moved my app from using actionbar to toolbar however end up with the error (full error at bottom). My code: My Activity: public class MapsActivity extends ActionBarActivity implements LocationListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_maps); ... mDrawerLayout.setDrawerListener(mDrawerToggle); toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled