Android Lollipop, AppCompat ActionBar custom view doesn't take up whole screen width -


So, I just updated my codebase to Lollipop, and I'm having problems with the action bar. I AppCompat and ActionBarActivity , And a custom view is growing. It seems that the custom view no longer takes the full width of the screen, leaving a thin strip on the left

the way it is used to see

 Building with 21 It now appears

This is the code that I am using to set the action bar. Anyone have any ideas?

Last ActionBeer Actionbars = getSupportActionBar (); Aug R (actionbar! = Null) {actionBar.setDisplayHomeAsUpEnabled (wrong); actionBar.setDisplayShowHomeEnabled (wrong); actionBar.setDisplayShowTitleEnabled (wrong); actionBar.setDisplayShowCustomEnabled (correct); actionBar.setNavigationMode (ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setCustomView (R) .layout.action_bar_content_search_custom_view); actionBar.setBackgroundDrawable (zero); // Actionbar System.Stextbackgrounddable (empty); TextView title = (TextView) verb Bar.getCustomView (.) FindViewById (R.id.action_bar_title); Title.setText (R.string.youtube); ImageView Back = (ImageView) verb Bar.getCustomView (). FindViewById (R.id.action_bar_back); Back.setOnClickListener (New OnClickListener () {@Override Click Public Zero (see V) {Finish ();}}); }

Edit

Taking the custom view and changing the background now raises the entire width, the problem is that we How can the full width of the custom actionbars take?

Looks like in the actionbar in the recent app-com -W 7 is due to the latest changes in the update. Looks like you have important changes to how action bars should be handled.

I had to face the same problem and after reading, and especially in the following quote I found a solution.

With Android L (API level 21), the action bar can be displayed by any Toolbar widget in the App Layout. The app can indicate activity as the toolbar should be treated as the action bar of activity. One of the activities using this feature should be used. Set any ActionBar theme, WindowExtbar attribute to false or otherwise request a window feature.

The way I see it, the AppCompat topics were changed and on one side there were some things to break, but on the other I offer more flexibility. Follow the steps:

  1. Use the .oActionBar style in your activity described in the above quote
  2. Create a Add android App: contentInsetStart = "0dp" set the attribute
  3. Support.v7.widget.Toolbar in your Activity Layout This is your main question in your measurement The main issue related to
  & lt; 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 / actionbar" Android: layout_width = "match_parent" Android: layout_height = "wrap_content" app: contentInsetEnd = "0dp" app: contentInsetStart = "0dp" & gt; & Lt; /android.support.v7.widget.Toolbar>  

It is generally recommended that you do this in a different layout file and use include in your activity layout so that you only have one The toolbar needs to be customized in place. Used in many activities

  & lt; Layout = "@ layout / visual_appress_bar" />  
  1. Use findViewById and setSupportActionBar in your activity onCreate From the signal for the activity which should be considered as the action bar of the toolbar
  Toolbar action equals = (toolbar) findViewById (R.id.actionBar); SetSupportActionBar (ActionBar);  
  1. Once you do this, all the jobs added to the onCreateOptionsMenu in the toolbar will be added and it will be added to the activity The action bar will be considered as.
  2. Customize Toolbar as desired (add hair view and more)

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -