Cannot make child view wider than parent view in Android layout

I move the view after the animation is complete (to display the menu on the left). However, it seems that I cannot achieve the effect that I am looking for. I would like the view to expand to the right edge of the parent borders, for example:

What i want

but what really happens:

Actual Result

The view resets itself to remain within the parent. Even if I set the absolute value of the pixel (looking at the width of the screen or even at a random large value).

The reason I need to do this is detailed in this SO question about the actual position of the view after the animation is completed: TranslateAnimated ImageView is not available after the animation [Android]

any thoughts? Thanks!

+6
source share
2 answers

So here is the question. It explains how to move a view from the screen.

+3
source

I had the same problem and found a solution. Hope this can be helpful. You need to set a fixed width if you want to achieve this effect. To find the actual viewing width, you need to measure it. So the complete solution:

view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); int height = view.getMeasuredHeight(); int width = view.getMeasuredWidth(); view.setLayoutParams(new LinearLayout.LayoutParams(width, height)); 

(Use LayoutParams for the type matching the type of the parent layout)

+1
source

Source: https://habr.com/ru/post/902871/


All Articles