2016-08-15 3 views
0

Ich habe eine LinearLayout mit 9 statischen Kindern. Ich möchte 2 Kinder (in der Reihenfolge childAt(0) und childAt(1)) als ViewGroup bekommen, um eine Animation anzuwenden. Ich möchte keine neue LinearLayout erstellen, weil ich zuerst die Kinder von ihren Eltern entfernen muss und es wird tatsächlich die Kinder entfernen, und ich tue es nicht, da ich diese Kinder nur gemeinsam animieren möchte.Wie erhalten LinearLayouts Kinder als Viewgroup?

Zum Beispiel:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingLeft="16dp" 
    android:paddingRight="16dp" 
    android:orientation="vertical" > 
    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:hint="@string/to" /> 
    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:hint="@string/subject" /> 
    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:gravity="top" 
     android:hint="@string/message" /> 
    <Button 
     android:layout_width="100dp" 
     android:layout_height="wrap_content" 
     android:layout_gravity="right" 
     android:text="@string/send" /> 
</LinearLayout> 

Ich mag Kind bekommen 2 und 3 als ViewGroup.

+0

seit LinearLayout ist bereits eine Viewgroup, gibt es eine Möglichkeit, Kind 2 und 3 als Viewgroup zu bekommen? – cyberlyn06

Antwort

0

Meinst du ViewGroup.addView(View)?

viewgroup.addView(lview.childAt(0)) 
viewgroup.addView(lview.childAt(1)) 
+0

Dies funktioniert nicht, da Sie eine Viewgroup erstellen müssen. Ich bin mir nicht sicher, ob wir 2 Kinder in onLayout() zusammenführen können. 'ViewGroup viewGroup = neue ViewGroup() { @Override geschützter void onLayout (boolesch b, int i, int i1, int i2, int i3) { //? } } ' – cyberlyn06

Verwandte Themen