Animate listview from back of layout

2020-02-01 12:14发布

问题:

I am working on animation, I have one Layout and list-view and I am applying animation to list-view from left to right, Its working fine but list-view slide front of layout and I want to do from back of layout.

On click of layout list-view will slide from left to right and it hold the place beside layout like below images.

Thanks.

回答1:

Try to Understand the View order(Hierarchy) let me make it clear with an example

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
> 

<TextView 
android:id="@+id/tvMessage" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="dasdjfiuihuhds" /> 
<Button 
android:id="@+id/btnOk" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="Ok" /> 

</RelativeLayout>

This will make Textview over ButtonView

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
> 
<Button 
android:id="@+id/btnOk" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="Ok" /> 
<TextView 
android:id="@+id/tvMessage" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="dasdjfiuihuhds" /> 

</RelativeLayout>

This will make Button over TextView

1st case code

<RelativeLayout > 
<TextView> 
<Button>

2nd case code

<RelativeLayout > 
<Button> 
<TextView>

in Short you can maintain order by following code hierarchy