android-toolbar

Back navigation with Fragments / Toolbar

家住魔仙堡 提交于 2019-12-22 05:25:11
问题 I'm scratching my head with this one now.... I have an ActionBarActivity that loads an initial Fragment - the original menu is inflated within the activity. Now, I have a navigation bar that, when an item is selected, loads a different fragment and adds this to the backstack. When I do this, there are a couple of things I want to set: Set the home as up indicator Invalidate the options menu from the main activity Set has options to true for the Fragment Ensure that the up indicator correctly

How to hide navigation drawer when opening certain fragment?

孤街醉人 提交于 2019-12-21 19:59:55
问题 I'm pretty new in android development. I want to hide navigation drawer when user is not logged in. So basically, it will shown login fragment (better in full screen like Facebook android). And if user already logged in, navigation drawer will always shown. MainActivity.java public class MainActivity extends AppCompatActivity { private DrawerLayout navDrawerLayout; private Toolbar toolbar; private ActionBarDrawerToggle navDrawerToggle; private SharedPreferences pref; @Override protected void

Change toolbar back arrow color

ε祈祈猫儿з 提交于 2019-12-21 17:49:10
问题 Hi. In the picture above you can see a back arrow and a (part of) title. I changed the title color using the attached .xml code. But I want to color the back arrow to white too. I read some answer on the internet, but they look too complicated for such a simple question. Is the any simple why to do it? <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="fill_parent" android:layout_height="?attr/actionBarSize" android:background="@color/colorPrimary" android

Change Custom Toolbar Text

∥☆過路亽.° 提交于 2019-12-21 15:15:14
问题 Unable to get the text on my toolbar to change. I have done a tone of searching but I am seeing no results. I have tried so many combinations of things but maybe something will pop out. Here is the code for the last thing I have tried for my activity. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbarCustom); TextView textView = (TextView) toolbar.findViewById(R.id.toolbarTextView); textView.setText("String"); Here is my XML Code <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns

Show different menu options on Toolbar for activity and fragment

那年仲夏 提交于 2019-12-21 09:27:24
问题 Android Studio 1.4 I have a Toolbar that I inflate in my activity_main.xml . I have a menu called main.xml that gets inflated that has just 1 icon to display on it. When the user clicks to open a fragment. I have another menu friends.xml that has 2 icons. When I inflate the friends menu in the fragment it still displays the icon from the main.xml menu. I thought that inflating a new menu on the toolbar would remove the existing menu. This is a screenshot of the main.xml menu. The find icon is

how to set toolbar on FragmentActivity?

前提是你 提交于 2019-12-21 07:14:03
问题 I want to set toolbar on my activity which extends FragmentActivity . I know that for use setSuppoertActionBar(toolbar) method we extends AppCompatActivity instead of FragmentActivity but I override the onMenuItemSelected(int featureId, MenuItem item) method which is final in AppCompatActivity and final method cannot override. so I'm restricted to extends FragmentActivity . Here is my code: public class MainActivity extends FragmentActivity { @Override protected void onCreate(Bundle

How to have a textview transition to the title in a collapsing toolbar?

回眸只為那壹抹淺笑 提交于 2019-12-21 05:32:15
问题 I have a CollapsingToolbarLayout that contains a TextView and a RatingBar under the TextView . Would it be possible to have the TextView somehow transition to the title? My current layout looks like this: I want "Title" to transition up as the toolbar collapses. There will also be a back button, so how would I ensure that the textview transitions to the proper place (to the right side of the back button)? EDIT: Here is my XML <android.support.design.widget.CoordinatorLayout android:id="@+id

How to change toolbar icons color on collapsing

好久不见. 提交于 2019-12-21 04:04:43
问题 I'm using CoordinatorLayout in my project . It works fine but there is a problem I need to fix .I'm using white actionbar icons and When the CoordinatorLayout is expanded and the background color is white, I can't see any of those icons . I saw this in an application . when the CoordinatorLayout is expanded , the icons are dark and when scrolling down, they begin to change into white . as you can see, when it's expanded the icons are dark and when it closes , the icons becomes white . it

Set menu item background color on hover in Android

有些话、适合烂在心里 提交于 2019-12-20 20:15:08
问题 I have menu items in my app, and I would like to change color of item background, when it is clicked (please see screenshot - item 1 is clicked) I just want one color here - either light blue, or dark one. However, as you can see, there are two of them on the first item. Here is my code: Toolbar in activity: <android.support.v7.widget.Toolbar xmlns:sothree="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/main_toolbar"

How to add a spinner next to a menu in the toolbar

我是研究僧i 提交于 2019-12-20 19:39:05
问题 I want my spinner to be next to my menu in the toolbar (to the left of the menu), but currently the spinner appear below the menu. Do i have to add it somehow inside the onCreateOptionsMenu(Menu menu) My Activity: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_list); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayShowTitleEnabled(false); Spinner