1

Android Wear で RotationAnimation (ImageView) を実行しようとしています。

Android タブレットでサンプルをテストしたところ、問題なく動作しましたが、Android Wear では ImageView が表示されなくなりました。

どうすればアンドロイドウェアでできますか?

これはレイアウトです:

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

    <Button
        android:id="@+id/rotatecenter"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Rotate around center"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:gravity="center"
        android:weightSum="1">

        <ImageView
            android:id="@+id/floatingimage"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher" />

    </LinearLayout>

</LinearLayout>

これはrotationanimation xmlです:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator">
    <rotate
        android:fromDegrees="0"
        android:toDegrees="360"
        android:pivotX="50%"
        android:pivotY="50%"
        android:duration="2000"
        android:startOffset="0"/>
</set>

最後に、これはアクティビティ コードです。

Animation rotate;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my2);

        Button buttonRotateCenter = (Button)findViewById(R.id.rotatecenter);

        final ImageView floatingImage = (ImageView)findViewById(R.id.floatingimage);

        final Animation animationRotateCenter = AnimationUtils.loadAnimation(this, R.anim.rotate_center);
        buttonRotateCenter.setOnClickListener(new Button.OnClickListener(){

            @Override
            public void onClick(View arg0) {
                floatingImage.startAnimation(animationRotateCenter);
            }});


    }

ありがとう。

4

0 に答える 0