2017-08-05 123 views
0

我在LinearLayout中有3個元素,我需要爲其中的一個設置動畫。
當動畫開始時,元素不在其他元素之上,但它保持在下面。
我已經嘗試使用bringToFront()但它不起作用(更改命令如doc說)。
我需要爲此「垂直」佈局設置動畫「@ id/ton」的元素。Android線性佈局z-order動畫

<LinearLayout 
    android:id="@+id/wrapInfo" 
    android:layout_width="0dp" 
    android:layout_height="match_parent" 
    android:layout_weight="1" 
    android:layout_marginLeft="5dp" 
    android:layout_marginRight="5dp" 
    android:focusable="false" 
    android:layout_gravity="center_horizontal" 
    android:orientonion="vertical" 
    android:clipChildren="false" > 

    <ImageButton 
     android:id="@+id/imageView1" 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:layout_marginBottom="5dp" 
     android:background="@null" 
     android:focusable="false" 
     android:focusableInTouchMode="false" 
     android:layout_gravity="center_horizontal" 
     android:src="@drawable/yourlogohere" /> 

    <TextView 
     android:id="@+id/ton" 
     android:layout_height="0dp" 
     android:layout_weight="2"/> 

    <WebView 
     android:id="@+id/web" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight = "1" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     /> 

</LinearLayout> 

在這種情況下,TextView低於WebView。
我使用LinearLayout,因爲我需要這些元素是設備高度的25/50/25%(我使用weight xml屬性)。

回答

-1

Z-Order是ViewGroup兒童數組中的索引,如果您想更改順序,則使用removeView(),然後使用新索引添加addView()。

在LinearLayout的情況下,如果視圖添加了索引0,它將放在最上面,而如果視圖添加了index == viewGroup.getChildrenCount()-1,它將放置在較低的位置。

並致電viewGroup.requestLayout();以後