1

私の活動のレイアウトは次のとおりです。最初に「heightView」の重みを 100 に設定します。次に、起動の 4 秒後に、heightView の高さを 51 にアニメーション化して、内部の「LinearLayout」のスリング効果を作成できるようにします。

私はアンドロイドに非常に慣れていません。

マイレイアウト XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/main_bg"
    tools:context=".MainActivity" >

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:layout_gravity="bottom"
    android:weightSum="100">
        <View 
        android:id="@+id/heightView"    
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="100" />
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="41"
        android:orientation="horizontal"
        android:background="@drawable/menu_repeat"
        android:tileMode="repeat" >
<ImageButton
        android:id="@+id/contactBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent"
        android:src="@drawable/contact" />

<ImageButton
        android:id="@+id/events"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent"
        android:src="@drawable/events" />

    </LinearLayout>


</LinearLayout>



</RelativeLayout>

私のJavaコード(動作していません)

setContentView(R.layout.activity_main);


View myView=(View) findViewById(R.id.heightView);

ObjectAnimator scaleYOut = ObjectAnimator.ofFloat(myView, "weight", 50, 0f);
AnimatorSet set = new AnimatorSet();
set.play(scaleYOut);
set.setDuration(1000);
set.start();

助けてください よろしくお願いします

4

1 に答える 1