Prevent Keyboard layout hiding toolbar but reveal scroll content - java

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);

Related

How can I detect tab focus changes in an android TabLayout?

I have a ViewPager set up with a TabLayout at the top. The app is running on a device with physical d-pad directional keys that can be used to move the control focus.
How can I detect when the focus is moved to specific tabs in the TabLayout?
I can see the Tab highlight when the focus is received, but I am unable to find any events that might allow me to detect this.
Also, TabSelected doesn't work, as it doesn't fire until the center key of the d-pad is pressed to "select" the focused tab.
You can add custom view to your tab, and then setOnFocusChangeListener for this view.

How to expand a cardView to show hidden elements in android with a dropping animation?

I am beginner in android animations and therefore, am wondering exactly how can I implement something like expand a cardView to show hidden options or elements.
For example: a post in social networking, we have a cardView holding the post info. it also has likes and comments buttons/options. When user taps on comments button the view should expand a little say certain height and show the comments and shrink back when the same button is tapped again.
I am listing my posts using RecyclerView in a Fragment using a CardView. I am looking for a soft animation along with expanding and shrinking back to original place or size.
Below is a screenshot that might help you understand what exactly I want:
How to do this? Will you please provide me a small snippet of code?
use wrap content as height of cardview and use textview inside it below title, so on click make the textview visible and invisible.
And use android:animateLayoutChanges="true" in parent layout.

Android Scrollview gets overlapped by a view and keyboard

I have searched the web for about 2 hours and no solution, now I will try it here.
My problem is that when I open the keyboard the scrollview gets overlapped by a view and the keyboard. I want to see the bottom elements of the scrollview.
Here are the screenshots: screenshot1, screenshot2.
The scrollview doesn't respond to adjustReize like other views do, the solution (like other people have done e.g. Why doesn't android:windowSoftInputMode="stateVisible|adjustResize" adjust the screen when soft keyboard is shown?) will simply listen to the view's hierarchy and scroll to the bottom when the keyboard is shown

Set initial size for collapsing toolbar, expand or collapse

I'm using android support design library to create a collapsing toolbar. It works great, my view collapses when I scroll and expands when I scroll back.
But I wonder, I would like to have a profile in this toolbar, but half the profile would be hidden at first. So for example at first you only see the users profile picture in the toolbar. If you scroll down the list the toolbar collapses and everything gets hidden. But if you scroll the other way, to the top of the list and kind of beyond, the toolbar will expand even more and show you both profile picture and more information like name, description and so on..
Is this possible? To set the toolbar like "half collapsed" or something similar.
After a lot of trying and searching for information about the collapsing toolbar I ended up using another library instead.
https://github.com/umano/AndroidSlidingUpPanel
With this I got the customisation I wanted by setting anchor points. Though I didn't get, or atleast I don't know how to get, the function of the toolbar expanding and changing from toolbar color to an image for example. But for my case, the customisation was the main function and thus more important.

How to get informed about scrolling over the top of a ScrollView

Can somebody help me? I have an activity with a ViewPager in it. The Pages (Fragments) uses vertical ScrollViews. How can i realize, that a user who wants to update its contents can do it like in other apps e.g. Facebook? I mean, if the user is on the top of a ScrollView and he try to scroll up again, then there should open a loading-animation on the top of the ScrollView and a function loads data from a web sever....
So how i can get notified about the scroll up gesture of the user ?
I know that i will need a "invisible" view above the scrollView wich became visible when the user scroll "over the top" of the scrollView. The Animation and the dataexchange with the web server still aren't a problem - i will do it in an async task. My only question: where i have to listen on, to get informed about the scroll gesture over the top of the ScrollView?
Thanks,
Greets
PS: Sorry for my english - i am not a native english speaker.
Use OnScrollViewListener her is example for how to use it

Categories