How to change toolbar direction in API 16? - java

I have problem with changing ActionBar(Toolbar) direction from LTR to RTL in Navigation Drawer Activity.
Also tested different codes but even when whole of program direction changed, the toolbar did not change.
Can you help me?

Related

How to make a Bottom Navigation bar with ImageView instead of Menu Items?

How can I make a working bottom navigation bar with ImageViews in a LinearLayout(Horizontal) With fragments ? instead of menu items.
if already exist then please share the source code. Please help quickly :)
Or the Question could be this :
https://github.com/qhutch/BottomSheetLayout/issues/12#issue-576279364
Oh, I found my solution not exactly but this is what I want...
I add that Bottom Navigation View in a LinearLayout(horizontal) and I delete all default Styles from BottomNavigationView. So now this is not looking like a card view. After this, I add an ImageView in the LinearLayout with a weight of a ratio of 1:3 (for 4 icons ). Now I can use effects and designs on my LinearLayout. And it is looking like how I wish. 😌
[Note: For horizontally rotated screen LinearLayout, ImageView, BottomNavigationView 's width:match-parent]

How to show Hamburger Icon, when toolbar icon is enabled

For my App i need to show icon in toolbar. So I referred a question on stackoverflow
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setIcon(R.drawable.ic_launcher);
I applied the same to my code but after running the app i noticed my navigational drawer icon i.e. hamburger gone missing.
How can i get it back along with the app icon?
Remember, ToolBar is the more customizable version of ActionBar, and are two different things, though they basically follow the same pattern.
My answer is to user Toolbar and customize it for the required view instead of using the default ActionBar.
If you are using the customized ToolBar, then the below code is not going to work.
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setIcon(R.drawable.ic_launcher);
Use ToolBar.
Change from this
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setIcon(R.drawable.ic_launcher);
To
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_launcher);

How to open NavigationDrawer in portrait mode while my activity is in landscape?

So, I am trying to open NavigationDrawer in portratit mode, but I have to lock my activity in landscape mode due to some reason.
I have tried to set gravity to left or right but all of them open NavigationDrawer as it should open in LandScape mode, but I want it to ope in Portrait mode.
There is nothing in documentation about such case and from what I know Navigation Drawer is usually used from sides.
You may however check gravity
https://developer.android.com/reference/android/support/v4/widget/DrawerLayout.html#openDrawer%28int%29
There are also other navigation components like Bottom navigation which may fit better in your case.

Prevent Keyboard layout hiding toolbar but reveal scroll content

Best description for my issue was at
Keyboard layout hiding android action bar?
And I will paste-quote here:
"I have this problem also but the difference is, i have a list above my edittext and can't use a scrolling container. If I use adjustResize when the edittext is focused it appears above the list and the last items from the list get obscured (list is not pushed up). If I don't use adjustResize on the other hand, when the edittext is focused it pushes everything up but the acionbar is hidden and also I cannot scroll to the top of the list. Can someone share a solution for this? "
So
I have a toolbar
then a chat content
and then a bottom bar for sending a message (editText and a button)
Now, when I tap on an ediText, and soft keyb opens up, I do NOT want my toolbar to collapse and hide, but I do want my chat content to scroll up, so above the bottom entry I will see the last messages from chat content (in listView).
I've tried a number of combinations for Activity adjustResize or adjustPan, but none of them was working. Even wrapped toolbar in CoordinatorLayout and AppBarLayout, but still, no results. Either my content gets pushed/scrolled correctly but toolbar hides OR toolbar stays but softKeyboard overlaps last couple of messages.
The solution I share is a workaround. I had implemented a function scroll(), to scroll my content if a new message arrives, so that was one function I implemented before. I was missing the other part and that is, detect when a softKeyboard was open so I can scroll my content.
That was easy to find here on
How to check visibility of software keyboard in Android?
I hope someone will find this workaround useful and sleep at least a couple more hours.
Note:
Animation of sliding content up is not consistent with softKeyboard sliding up. After keyboard is opened, then I do scroll, which is not in-sync. It is just a snap. But I don't care about that until I find a better solution for orchestrating this event using a native Android component or layout.
The easiest and best solution to all of the above is to simply use the following:
listView.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);

Navigation Drawer right gap

in the dev guidelines they say the gap to the right displayborder shall be 56dp if the nav drawer is opened. How can I do that? Because in the xml "match_parent - 56dp" doesnt work. :D
Guidelines
Thx for help!
I think it's 56dp by default for most Drawer widgets like android.support.v4.widget.DrawerLayout
The equivalent for "match_parent - 56dp" would be layout_width="match_parent" and layout_marginRight="56dp" for your xml view or layout inside your bigger layout.

Categories