2016-04-27 7 views
0

サーバから値を受け取ったときに、ホイールを動的に回転させる必要があります。Android:サークルメニューが動的に回転する

私はWheelMenu libraryを使用しています。

wheelMenu.setAlternateTopDiv(int); このコード行を使用しても、ホイールの回転に違いはありません。

ここは自動的に回転したいホイールです。事前に

enter image description here

感謝。

答えて

2

こんにちは私はライブラリをダウンロードし、ドキュメントを読んでいます。ことは、ライブラリはあなたがしたいことをしないということです。メソッドwheelMenu.setAlternateTopDiv(int)は、ホイールの参照選択を変更するだけです。

イメージを自動的に回転させたい場合は、アニメーションを使用して、ある角度の回転を行い、必要な位置に移動します。

EDIT:

あなたが90度のためにあなたはボタンではなく、無アニメーションをクリックするたびに画像をオンにこのコードを試すことができます。それを試して、あなたが望むものがあれば教えてください。

public class MainActivity extends AppCompatActivity { 

private ImageView imageView; 
private Button button; 
private float rotation = 0; 

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

    imageView = (ImageView) findViewById(R.id.image); 
    button = (Button) findViewById(R.id.button); 

    button.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      rotation = rotation + 90; 
      imageView.setRotation(rotation); 
     } 
    }); 
} 

@Override 
protected void onDestroy() { 
    super.onDestroy(); 

} 
} 

レイアウト:

<?xml version="1.0" encoding="utf-8"?> 
<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:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
tools:context="com.gohidoc.realmtest.MainActivity"> 

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

<Button 
    android:id="@+id/button" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="turn"/> 

</RelativeLayout> 

画像:

Wheel

+0

はい、私はこれを行う必要があります。どうすればいいのですか? –

+1

@RobinRoyal私が編集した内容を試してみてください。アニメーションやその他のユースケースのヘルプが必要な場合はお知らせください – Chami

+1

@RobinRoyalニュース? – Chami

関連する問題