I'm trying to do a shared element transition with a TextView between an item in a list, and it's detail view.
The transition itself is working correctly, the text and images are moving both to the details fragment, and back to the list to the correct locations.
The problem I'm having is the TextView on the list has left gravity, and the TextView on the detail has center gravity. When the transition happens, it's keeping the left gravity of the original TextView.
It's only after I call requestLayout() in code or click on an actionable item on the screen, that the text centers itself which won't work. I've tried this with and without the onPreDrawListener where you use startPostponedEnterTransition and it's the same problem.
Is there something I need to specifically do so the transition goes to the correct centered location on the detail view immediately?
I don't quite have time to make a sample app of this happening, but I'll have time next week if it's needed. I'm hoping there's just some weird flag that I don't know about and can't find that would resolve this.
Related
Is it possible on selected CardView swipe up or click (if swipe up not possible) to make CardView fill ~90% of the screen. And when clicked again, it shrinks down to its original form.
The important part is that it has to be on the same view as google maps are, so transition to other activity won't work for me and also I will be adding addition content to CardView when it will be enlarged.
I don't need exactly specifics on how to do it, but at least where to start.
Right now you can swipe left and right, and it will add shadow to object and enlarge current item.
Link to .xml and transform class code: https://pastebin.com/0trtw1E1
Basically, i'm trying to implement https://github.com/mciekurs2/ViewPagerCards, but with a little bit of a twist.
I have a details fragment that is using a DetailsOverviewRow and FullWidthDetailsOverviewRowPresenter. When the page first loads the action buttons are selected. When I press down once, focus leaves the buttons and nothing else happens. When I press down a second time focus moves to a ListRow that is further down the page. I'm trying to figure out why the overview, or body as it's called in the presenter, section doesn't focus.
Should there not be a second 'state' between the two screenshots where the overview/body is readable?
Possibly of note. The DetailsFragment isn't declared in an activities xml, I'm changing fragments manually using FragmentTransactions. Also, the Fragment is instantiated using a static create method (source below).
Thanks in advance.
Activity xml
DetailsFragment java
I haven't tried this example in particular, but from my time spent with Leanback support library, I learned that even though a lot of helpful stuff is indeed provided, a lot is not :D
So I would try these things:
1) Make sure that something in the area you want visible is focusable. (Clickable elements should be focusable by default, but better check too) What I mean is that on the screenshot, there is just text, no buttons or editable content in that area. So when you press down, there is nothing to focus. What happens if you make the body TextView focusable?
(Yes, one would expect that the support library would take care of that, but that might not be the case.)
2) Find out what actually gets focused when you press down, since as you said, the focus leaves the buttons - but where does it go? (How to find out which view is focused?) You might have a "direction problem" somewhere. That is - the focus travels based on the view hierarchy tree, not based on what we see on the screen. In some cases, it is possible to skip some elements or get stuck somewhere by moving focus through an unexpected part of the view tree, that makes sense for the algorithm, but isn't logical from the human perspective.
The details presenter focus works this way :
1) First focus is given to Action buttons. Right/left nav press shifts the focus right/left between action buttons.
2) Down nav press from actions row shifts the focus from actions row to details row (individual details items itself are not focusable), this is achieved by shifting the Thumbnail anchoring position to further south.
3) Down nav press from details row shifts the focus from details row to related row.
So the details row gains focus by changing the anchoring position of Thumbnail image. Is your thumbnail image changing its anchoring position when pressing down from actions row?
Hate to answer my own question. This was due to my failure to RTFM. I was creating the fragment UI after a network request completes. For the FullWidthDetailsPresenter to work properly it and the ClassPresenterSelector() should be initialized in the fragments onCreate() method.
I would like to know whether it is possible to change the z-order of a shared element transition? Look:
I have a layout with an image, that fills the whole screen. In front of the image is a textbox which shows the title of the image. If I klick on the textbox, the transition to the detail activity starts. Therefore I implemented a shared element transition, in which the fullscreen image animates to a smaller version of itself in the detail view. The picture below illustrates this behaviour.
My problem now is that in both activities are textboxes, that are placed above the shared element image. And if I went from overview to detail activity, I see the circle textbox with the number only after the shared element transition is finished.
I would like to place the textbox with the number above the shared element transition, so that I could do an animation on this view element, too.
any idea on how to solve this?
If I'm not mistaken, android calculates which views are on top of others by using the elevation of the views. Try playing around with the elevations (or the translationZ values) to decide which view(s) should be on top.
Solution : ViewGroupTree
Solution
level 0 : MainConstraint //(your row)
level 1 : ImageView / Otherlayout
level 2 : TextView
item A::BackgroundImage : MainConstraint -> ImageView
item B::BackgroundTextView : MainConstraint -> Constraint -> TextView
With this, the layout are Z index order are messed up.
because ImageView and TextView have different layout hierarchy, add your ImageView inside an other layout and it's will work as expected !!
You have to use the same level of deep for each of your view to get a, expected call
I hope it's not late ;)
I have a text view where in i have to keep ages between 1-99. I also have two buttons ^ and v(i mean up and down arrows) on clicking them the values of the age should smoothly scroll to next or previous value.
I have been trying different ways but couldnt achieve smooth scrolling. Can anyone please give me any idea of how to achieve the task.
I think the easiest way is to simply put the TextView within a ScrollView, and let the arrows interact with the ScrollView, by using things like the fling method and playing around with the velocity parameter to suit your needs.
Use the animation framework.
When pressing down, start the 'down'-animation.
When pressing up, start the 'up'-animation.
Read more about animation here: http://developerlife.com/tutorials/?p=343
View animation is not much matured and hence i am noy sure if that can be used for moving the views.
Please find the description below:
Another disadvantage of the view
animation system is that it only
modified where the View was drawn, and
not the actual View itself. For
instance, if you animated a button to
move across the screen, the button
draws correctly, but the actual
location where you can click the
button does not change, so you have to
implement your own logic to handle
this.
Source
To scroll smoothly you can try using the scroller component.
Reference
What you would need to do is pass the duration of the scroll in the constructor and then use the property
setFinalY(int newY)
to increment the counter position by 1 unit (equal to the height of the item).
Please let me know if that helps!
I have a ListView and each item contains a TextView displaying a number. I'd like to give my users the ability to change this number while staying on the ListView (as opposed to drilling down into a detailed view by clicking on the list item).
What I'm looking to do is to slide in a layout from the bottom of the screen that covers about half of the screen. I'd like this layout to be OVER the Activity behind it (as opposed to being part of that Activity's layout and simply showing it). I'd also like it to be model (or seem modal). Meaning the Activity behind it can not be focused and manipulated. In this layout I will essentially create a calculator.
What I need help with right now is:
1) How to display a layout over the current Activity
2) How make the background (the Activity) modal
Could someone point me to some tutorials/resources and/or give me a few tips?
use an Animation. here is a small tutorial on them: http://developerlife.com/tutorials/?p=343
initially, the view you want to be modal must be placed where you want it to show up(and visibility set to gone).
use a translate animation to visually move the view from below the screen to halfway up the screen. once the animation starts, set visibility to visible
try disabling all views that the user should not be able to interact with after you have started the animation holding the calculator view