Rotation autour d'un point en gardant la même orientation
Bonjour,
Je veux faire une rotation (animation) d'un objet (un bouton) autour d'un point jusqu'à la j'ai réussi.
Le problème c'est lorsque l'objet tourne autour du point il tourne également sur lui-même et moi je voudrais qu'il garde la même orientation pendant qu'il tourne autour du point(pivotX, pivotY).
Comme dans l'exemple: http://dabblet.com/gist/4389712 mais sous Android.
Comment je peut réaliser ce genre de rotation?
Mon code Java:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
public class MainActivity extends AppCompatActivity {
Button button;
float radius = 195.0f;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = (Button) findViewById(R.id.t);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
rotation();
}
});
button.setX(button.getX() + radius);
}
} |
Mon layout:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
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">
<CircularView
android:layout_width="match_parent"
android:layout_height="match_parent" />
<Button
android:id="@+id/t"
android:layout_width="50dp"
android:layout_height="50dp"
android:text="R"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout> |
Merci pour toute aide
Cordialement