I know (and use it) how to add a custom view to a Toolbar (as ActionBar). However my requirement now is to display that custom view below the title. Is there a way to achieve this without having to also include the title into that custom view? I prefer to leave the title management to the toolbar itself.
I understand the wrong thing !
You can try
View custom = getLayoutInflater().inflate(R.layout.custom,toolbar,true);
custom.setLayoutParams();
I'm going to bed.
you also can use the appbar ,
<AppBarLayout>
<Toolbar/>
<CustonView/>
<AppBarLayout/>
check the official documentation
http://developer.android.com/reference/android/support/design/widget/AppBarLayout.html
Related
have this layout -
<Stepsview
android:background="#color/white"
android:elevation="#dimen/margin_16"/>
this cast shadow at the bottom as well as top :
and what i need is :
Steps view and ActionBar are 2 different views, one way I see is to combine these 2 views inside a view group and set elevation on the view group only.
Is there any other way only controlling steps view.
Achieved it by dynamically adding the steps to the top abbbar ( container for toolbar ) and setting the elevation to the app bar itself.
Im searching for a specific Layout which I couldnt find in the internet. It somehow looks like a CoordinatorTabLayout but without collapsing while scrolling down/up. I founded this View in the App "BlackMusicPlayer" which looks like this:
When youre going to tap on the Picture the View is expanding. Should I create a new Layout from scratch or is there anything out there I could youse? Thank you
CoordinatorTabLayout is a custom composite control that quickly implements the combination of TabLayout and CoordinatorLayout.
may this github sample helps you
you can get reference of appBarLayout and try this
AppBarLayout.LayoutParams p = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
p.setScrollFlags(0);
toolbar.setLayoutParams(p);
Use coordinator layout with collapsing toolbar , and this will keep the collapsing toolbar always expanded
I am currently struggling to design my application the way i want to.
In my app i am using a NavigationDrawer and different fragments. By clicking on an item in the NavigationDrawer i swap out the fragment that is currently active.
There is one main fragment which shows a map and doesn't show a toolbar. When I switch to another fragment I want to show my toolbar and let the user interact with it.
Now when I show the toolbar I have to set the top margin of the NavigationDrawer to the size of the toolbar so it doesn't get overlapped.
When I am showing the toolbar I set the margin of the NavigationDrawer's listview like this:
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) mDrawerListView.getLayoutParams();
params.setMargins(0, drawerMarginTop, 0, 0);
mDrawerListView.setLayoutParams(params);
mDrawerListView.requestLayout();
The outcome is like the complete opposite of what i expect. It seems like the margin is applied to the bottom of the view.
Screenshot:
Another thing that annoys me is that the toggle-arrow of the toolbar is not centered correctly. It's a little bit higher than it should be, so it overlaps the system bar in the top and doesn't fill the whole size of the toolbar. I tried to make this clear in the following picture:
If you need any xml or code just let me know and I will edit my question.
Thank you in advance!
EDIT 1+2:
My toolbar style:
<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_navigation"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/my_color"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>
EDIT 3:
The Problem with the toggle-arrow not being centered is fixed now. Thanks to Alchete.
Unfortunately the NavigationDrawer is still buggy. I found out that if I open and close the NavigationDrawer many times it somehow changes its layout at one time and the margin is set correctly... Is there any way to force this top happen immediately?
After many times of opening and closing the drawer it looks like this: (Exactly what I want it to look like)
There must be a way to force this immediately, right?
Your alignment issue is most likely due to your toolbar height. You should be setting the toolbar height as follows:
<android.support.v7.widget.Toolbar
android:layout_height="?attr/actionBarSize">
Here's the same issue for reference: android.support.v7.widget.Toolbar icon alignment issue
I would also be using Google's IOSched app for reference on how to set these items up properly. You can find all the code on Github.
Here are their layout files. Scroll down to see their toolbar/navdrawer layouts: https://github.com/google/iosched/tree/dfaf8b83ad1b3e7c8d1af0b08d59caf4223e0b95/android/src/main/res/layout
And, also note that Google's reference design is to OVERLAP the toolbar with the navdrawer -- which is not how you have it. And, the right margin should be equivalent to the toolbar height.
See here: http://www.google.com/design/spec/patterns/navigation-drawer.html
I'm not 100% about this but it looks like you're setting the ViewGroup layout params to be of type MarginLayoutParams. Instead, set the margin on a 'normal' root ViewGroup type e.g. RelativeLayout and pass that to the View:
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT);
params.setMargins(0, drawerMarginTop, 0, 0);
mDrawerListView.setLayoutParams(params);
mDrawerListView.requestLayout();
You may want to change MATCH_PARENT to WRAP_CONTENT depending on your xml.
I've seen many of questions for how to add TextView in a RelativeLayout programatically, but everybody adding it in LinearLayout with orientation vertical. Can any one suggest me or give me a link that how to add multiple TextView in RelativeLayout at right until it has space and then change the line.
I want a layout like this..
May be this works for you !
You can customize chips-edittext-library for your need. Customizing by setting background to transparent, and editable to false.
-> Or you can use any other library which is used for displaying emoticon in EditText and customize it according to your need. Like android-emoticon-edittext-spike
You can use the Flow Layout library that manages the view arrangement itself.
When there is no space left the added View is moved to the next line
So I need the view of my settings to display over my main page.where there is a "setting"button in Main page which opens this settings view. But I want My main page to be visible beneath my settings view which only covers a half or less of the main view.
I tried adding
<org.example.myCustomView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:theme="#android:style/Theme.Dialog" />
Which I found from stackoverflaw itself. But I cannot do it instead the application corrupts at button click.
I am not sure I got this too correct, Or is there any other clear way to do it?
I replaced myCustomView with my relevent class and created the manifest also but it did not work.
If there is any other alternative way to do this mention to me.
I am not talking about how to place a TextView, Button, EditText on a view
I am talking about completely two layouts.
Below image is only an example to express my question.
I think you need to utilize layoutinflater. Here is a simple example how to use it
setContentView(R.layout.yourMainView);
LayoutInflater mInflater = LayoutInflater.from(getApplicationContext());
View overView = mInflater.inflate(R.layout.yourSmallView, null);
addContentView(overView, new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT));
Use FrameLayout.FrameLayout is like container.In it place first your bluelayout and then your settings layout.It will show as if settings layout is placed on top of your blue layout.
and then hide and show your settings layout on the onclick when required.
eg:
You could use a Dialog Fragment which would be much more simpler and show more complicated stuff on UI with better responsiveness. Have a look at Dialog fragment:
http://developer.android.com/reference/android/app/DialogFragment.html