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 need to set the RelativeLayout
's params but I have no idea what class it should belonged to (since it is parentless).
SomethingLayout.LayoutParams p = new SomethingLayout.LayoutParams(w*10, h);
A.setLayoutParams(p);
It would be great if someone can tell me how this can be done.
The reason why I need to do that is because I want to set 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.
And therefore I figured out that setting A's params can solve the problem. But I have no idea how to do that...