0

Here is my xmls (there are basically two views: a linear [B] inside a relative [A])

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/A" android:layout_width= "wrap_content" android:layout_height= "wrap_content" > <LinearLayout android:id="@+id/B" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> </LinearLayout> </<RelativeLayout> 

I'm setting the width of B as 10 times of the screen width, namely w*10:

RelativeLayout.LayoutParams para = new RelativeLayout.LayoutParams(w*10, h); B.setLayoutParams(para); 

When I animate B,

ObjectAnimator animation2 = ObjectAnimator.ofFloat(B, "x", -w) 

it shows that the width of B is w rather than w*10, as if A, who is being the parent view, is limiting its width.

What should I do to have B's width as w*10?

1

1 Answer 1

1

A child view must layout completely within its parent. You cannot ever be bigger than your parent, in either direction. So yes, a parent will limit the width of a child. Of course, since your parent is set to wrap content it should grow to surround B. Have you tried calling requestLayout to make it resize itself?

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.