Reputation: 437
I'm trying to scale a view (a ListView) to a certain size when the user clicks on an item in the ListView. The ListView's "original" (beginning) state is set to
layout_width="match_parent"
The ListView is obviously a rectangle, if you will. I can't figure out how to scale down the ListView and keep the left side of the rectangle(ie. ListView) "anchored" to the left side of the screen/parent-activity. All I want to happen is the ListView's right side to slide in from the right side of the screen/parent. The y-axis is not to be scaled or changed, only the right side of the ListView. I apologize if this isn't clear enough. Below is a crude picture of the beginning state and end state of the ListView upon a user click.
I appreciate any help, thank you.
Upvotes: 2
Views: 560
Reputation: 14044
if you are certain that you always have the expanded view first, then you could do something like this:
start by using match_parent as you currently do, to ensure it take up all the horizontal space of its parent container.
Override onWindowFocusChanged
of your activity to get the maximum required width
@Override
public void onWindowFocusChanged (boolean hasFocus) {
// myComponentToBeResized.getMeasuredWidth();
}
Store 50% of this value, so, you have the width of both the fully expanded and partially expanded view.
Update your view to use pixels (or dip) as width, instead of the match_parent keyword. Now, you can animate between the two values as you see if :)
Upvotes: 1
Reputation: 3020
you can try relativeLayout
and in this layout use your ListView
add android:alignParentLeft="true"
and android:alignParentTop="true"
to your ListView
then try using the scale animation on listView.By adding these attributes your listView
will be like fixed to the left side.hope it works.
Upvotes: 0