У меня есть следующий XML код, который не является Деятельностью, но является компонентом, который будет переработан во время многих Деятельностей:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#73808080">
<LinearLayout android:layout_weight="1" android:orientation="vertical" android:layout_height="0dp" android:layout_width="match_parent"/>
<LinearLayout android:layout_weight="30" android:orientation="horizontal" android:layout_height="0dp" android:layout_width="match_parent">
<LinearLayout android:layout_weight="1" android:layout_height="match_parent" android:layout_width="0dp"/>
<LinearLayout android:layout_weight="10" android:layout_height="match_parent" android:layout_width="0dp">
<LinearLayout android:layout_weight="1" android:layout_width="0dp" android:layout_height="match_parent"/>
<LinearLayout android:layout_weight="18" android:layout_width="0dp" android:layout_height="match_parent" android:orientation="vertical">
<TextView android:id="@+id/roundLabel" android:layout_weight="4" android:layout_width="match_parent" android:layout_height="0dp" android:autoSizeTextType="uniform" android:gravity="center" android:fontFamily="@font/segoeui" android:textColor="@android:color/white" android:text="Round"/>
<TextView android:id="@+id/roundValue" android:layout_weight="10" android:layout_width="match_parent" android:layout_height="0dp" android:autoSizeTextType="uniform" android:gravity="center" android:fontFamily="@font/segoeui" android:textColor="@android:color/white" android:text="1" android:textStyle="bold"/>
<TextView android:id="@+id/ofLabel" android:layout_weight="4" android:layout_width="match_parent" android:layout_height="0dp" android:autoSizeTextType="uniform" android:gravity="center" android:fontFamily="@font/segoeui" android:textColor="@android:color/white" android:text="of"/>
<TextView android:id="@+id/roundsLabel" android:layout_weight="6" android:layout_width="match_parent" android:layout_height="0dp" android:autoSizeTextType="uniform" android:gravity="center" android:fontFamily="@font/segoeui" android:textColor="@android:color/white" android:text="10" android:textStyle="bold"/>
</LinearLayout>
<LinearLayout android:layout_weight="1" android:layout_width="0dp" android:layout_height="match_parent"/>
</LinearLayout>
<LinearLayout android:layout_weight="30" android:layout_height="match_parent" android:layout_width="0dp" android:orientation="vertical">
<OpenDarts.Android.Components.Label android:id="@+id/playerNameLabel" android:layout_weight="4" android:layout_width="match_parent" android:layout_height="0dp" app:text="Player 1"/>
<LinearLayout android:layout_weight="1" android:layout_width="match_parent" android:layout_height="0dp"/>
<LinearLayout android:layout_weight="16" android:layout_width="match_parent" android:layout_height="0dp" android:orientation="horizontal">
<com.makeramen.roundedimageview.RoundedImageView android:id="@+id/userPhoto" android:layout_weight="10" android:src="@drawable/avatar" android:scaleType="fitCenter" android:adjustViewBounds="true" app:riv_corner_radius="30dip" app:riv_corner_radius_top_left="30dip" app:riv_corner_radius_top_right="30dip" app:riv_corner_radius_bottom_right="30dip" app:riv_corner_radius_bottom_left="30dip" app:riv_border_width="0dip" app:riv_mutate_background="true" app:riv_tile_mode="clamp" app:riv_oval="true" android:layout_width="0dp" android:layout_height="match_parent"/>
<LinearLayout android:layout_weight="1" android:layout_width="0dp" android:layout_height="match_parent"/>
<LinearLayout android:layout_weight="10" android:layout_width="0dp" android:layout_height="match_parent" android:orientation="vertical">
<FrameLayout android:layout_weight="1" android:layout_width="match_parent" android:layout_height="0dp">
<ImageView android:id="@+id/dart1" android:src="@drawable/dart" android:adjustViewBounds="true" android:layout_height="match_parent" android:layout_width="match_parent"/>
<TextView android:id="@+id/dart1Value" android:layout_width="match_parent" android:layout_height="match_parent" android:autoSizeTextType="uniform" android:gravity="center" android:fontFamily="@font/segoeui" android:textColor="@android:color/white" android:text=""/>
</FrameLayout>
<FrameLayout android:layout_weight="1" android:layout_width="match_parent" android:layout_height="0dp">
<ImageView android:id="@+id/dart2" android:src="@drawable/dart" android:adjustViewBounds="true" android:layout_height="match_parent" android:layout_width="match_parent"/>
<TextView android:id="@+id/dart2Value" android:layout_width="match_parent" android:layout_height="match_parent" android:autoSizeTextType="uniform" android:gravity="center" android:fontFamily="@font/segoeui" android:textColor="@android:color/white" android:text=""/>
</FrameLayout>
<FrameLayout android:layout_weight="1" android:layout_width="match_parent" android:layout_height="0dp">
<ImageView android:id="@+id/dart3" android:src="@drawable/dart" android:adjustViewBounds="true" android:layout_height="match_parent" android:layout_width="match_parent"/>
<TextView android:id="@+id/dart3Value" android:layout_width="match_parent" android:layout_height="match_parent" android:autoSizeTextType="uniform" android:gravity="center" android:fontFamily="@font/segoeui" android:textColor="@android:color/white" android:text=""/>
</FrameLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout android:layout_weight="1" android:layout_height="match_parent" android:layout_width="0dp"/>
</LinearLayout>
<LinearLayout android:layout_weight="1" android:orientation="vertical" android:layout_height="0dp" android:layout_width="match_parent"/>
</LinearLayout>
Из этого кода он запускает анимацию в ImageView с именами: Дарт1, Дарт2, Дарт3. Моя проблема в том, что анимация не доводится до вершины. Вместо этого изображение начинает двигаться и останавливается на самом первом «FrameLayout». Я хотел, чтобы ImageView оставался поверх всего.
Код, который приведен ниже, можно упростить следующим образом:
TranslateAnimation TranslateAnimation1 = new TranslateAnimation(0, 2000, 0, 0);
TranslateAnimation1.Duration = duration;
TranslateAnimation1.FillAfter = true;
TranslateAnimation1.AnimationEnd += TranslateAnimation1_AnimationEnd;
TranslateAnimation1.ZAdjustment = ContentZorder.Top;
dart1.StartAnimation(translateAnimation);
Я пытался использовать dart1.BringToFront (), но без успеха.
PS: Это Xamarin. Android, но API идентичен собственному SDK, с небольшими изменениями, такими как Pascal Регистр и другие незначительные изменения.