Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
Imagine having a panel, say an stickers panel (something like Viber or Telegram) in your app which needs to be visible and gone every now and then.
What would be the proper way of showing/hiding it? For example I used to change (animate) the height of the wrapper layout but it wasn't very performance friendly.
Should I just change the visibility and be done? Or a better way can be utilized? (Preferably an animated approach would be nice.)
Use view.setTranslationY(translationAmount), and animate with view.animate().translationY(-translationAmount).start().
translationAmount could be the height of the view, changing the sign of this measurement will invert the direction of motion.
A translation animation is much more efficient than changing the view height or other layout parameters because you don't have to traverse the view tree and re-draw everything.
you can apply animation to the view like
view.animate().translationY(distance);
applying view.setVisibility(View.VISIBLE); and view.setVisibility(View.GONE);is required to display and hide the view.
you will have a proper idea by referring this.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I'm a student in an android development program. I've built a few apps and I had an idea to use a very simple TextView to draw a line across the screen to visually separate a page element. The TextView would hold no text, it has no function or use other than to separate two elements with a horizontal rule. I'm using it in a ConstraintLayout.
Can anyone give me a reason as to why this is NOT a good idea? What would the best practices be otherwise? Is it normal to use an empty TextView in this manner?
It's perfectly fine to do that, but it's unnecessary to use a TextView specifically: A TextView with no text is just a View.
You can just create a View with whatever height and background color and use that:
<View
android:layout_width="match_parent"
android:layout_width="1dp"
android:background="#color/my_divider_color" />
Replace 1dp with whatever height you want and #color/my_divider_color with whatever color you want the divider to be.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I know how to animate translate, zoom and also value animator. But I'm wondering how to achieve the animation like notification drawer, the icon and button move and scale change as we drag down the notification drawer.
Please point out the tips and step to do the animation like this.
Thanks.
It would be better if you can give more details about what you want to achieve.
But I think you can try to using Motion Layout, it's now is available since Constraint Layout 2.0.
You can read more here
And also refer to vector icon animation here
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Does the fill_parent or match_parent attributes work for a relativeLayout object really?
Please see the following image:
match_parent works on any view.
As long as you don't have margins assigned to offset your view, it will expand to its parent size.
As for why you see it like this - do not rely too much on Android Studio designer. It is there to show a rough picture but is not a precise tool to rely on.
Best case to see things are fine:
set a temporary different background color for your view (RelativeLayout in your case) and its parent layout
load the app and check if the parent color is shown around your relative layout
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I try to achieve an View where i have multiple "cards" behind each other and where i could move and fling the Views away and the next "Page" shows up.
It Should be like in this Screenshot:
I tried using ViewPager, but that just allows me to "Scroll" horizontal and the way i try to put the View behind each Other ( margin etc. ) doesn´t really look good.
Then i tried to use a StackView, but this doesn´t work as expected, especially the move of the items.
Is there any best practice to achieve this with an ViewPager, or do i have to build something my own?
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
i need creating slider same as like iphone or android inbuilt lock slider in home screen app. for this functionality i will use any inbuilt control or create custom layout for this. anyone has info. regarding this than pls send me any link or details.
You will have to make a custom slider:
Use a seekbar widget.
Then, on the onStopTrackingTouch listener, reset the seekbar position to ZERO unless the rightmost value has been reached. This will have a "snapping" effect. You can also code an animation to bring it back to the initial position smoothly instead of the "snapping" effect. If the rightmost value has been reached, you can do whatever you wanted to do.
You can use custom 9-patch graphics too!