How to set text in recyclerview to the center with animation? - android

I have a recyclerview with expandable elements. When it expands I would like to have the text to align center-horizontally. I have tried to setGravity, but it is in ConstraintLayout and maybe because of that, it doesn't work.
Additionally, is it possible to add during this process with any fancy animation?

Related

Make middle View not push other view outside of bounds

I have multiple TextViews inside a horizontal LinearLayout and i need the middle text view to have ellipse=middle so that when the middle text is long enough, it pushes on both sides but the other views don't go out of bounds, but instead the middle TextView shows the '..."
Here's how it should look.
Setting the items normally, wrap_content for all in a horizontal LinearLayout will make the at ASAP text be pushed outside of the screen on Android (the above screens are from the iOS app).
Any ideas on how to accomplish this? Perhaps with a ConstraintLayout somehow ?!
Yes, i would recommend a ConstraintLayout. Top item to the top of the view, bottom item to thr bottom of the view then the middle item attached to these two views. You could also use barriers.

Android: How to change views in collapsing toolbar when scrolling

I am using collapsing toolbar. Is it somehow possible to achieve behavior, that will change multiple views in collapsing toolbar according to scrolling? For example I have three RelativeLayouts next to each other consisting of an ImageView (centered in parent) and text (below image) in collapsing toolbar. I want it for example to move image to left top, to move text to end of image and resize its height.
This wireframe shows a little what I would like to achieve:
Try use CollapsingToolbarLayout in the AppBarLayout.
Put big views to the CoollapingToolbarLayout. And Small views in the Toolbar.
You can try play with flag:
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
If you want create rely cool animation for text in the text view.
You must implement all behavior in Java code.

RecyclerView Remove/Add animations overlapping divider

I would like to know if it's possible to have the add/remove animations not overlap the divider like in the following video:
https://www.grokkingandroid.com/wordpress/wp-content/uploads/2014/08/recyclerview_animation.mp4?_=1
I am unsure as to how I can make the divider be bound to the item and not the view. Any help is useful.
Check the divider in SupportV7Demos app in AOSP. Basically, you should consider View's translateX/translateY properties when positioning your dividers.

Customized ListView with scolling background

EDIT: Solved this by from Java-code adding headers and footers with transparent background to the ListView.
Hi, I'm trying to make a ListView that has a gradient as a background and the content inside a frame. I have some screenshots of what I'm trying to acheive.
The first screenshots shows how I want it too look from start. The list is shown in a box with rounded corners and a green background. This is acheived by adding padding to the LinearLayout surronding the ListView. However, when I add padding on top, the scrolling looks like in the third picture, which is not what I want. The first field with name and phonenumber is a header for the listview.
Any suggestions on how to make the listview behave like this?
You should use Relative layout for solving this problem.

Attaching a fixed, transparent, header to a ListView?

I've been trying to get this working for some time... Is there any way to put a transparent fixed header on a listview, so it looks kind of like this:
As you scroll up, the header will eventually be a regular header with item 1 below it.
I guess I'll have to implement onScrollListener and do something like when the first visible item is item 2 in the list, start moving the listview margins by 1 pixel, until it is below the header? Or are there better ways? Any ideas on how one would do something like that?
I would make a FrameLayout... and put your ListView in it first, filling the screen. Then put a TextView on top of that. To get the desired behavior at the top, maybe have a blank element at position 0 of the list, or just make the top padding of list item 0 have the height of your header...
Does that make sense? The ListView should scroll underneath the TextView in a FrameLayout.
You can use a RelativeLayout for that, so you can get the Z axis using some properties;)
Update:
For example using a RelativeLayout:
RelativeLayout
----ListView
----TransparentHeader
Will appear in the way you show on your image.
As a comment :Android put layout elements in the order that they are defined on your xml, so, widgets at the bottom of the layout will be at the top.

Categories

Resources