0
私はオブジェクトを別の点の周りに回転(アニメーション)したいですが、オブジェクトを回転させながら同じ向きにします。私はそれをどうやって行うことができますか?Androidの関数を呼び出すだけで簡単にやることができますか?または数式を使用する必要がありますか?同じ方向を保って別の点をどのように回転させるか - アニメーションAndroid
マイコード:
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) {
rotate()
}
});
button.setX(button.getX() + radius);
}
}
マイレイアウト:
<?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: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">
<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>
あなたはトライしていますこれまでのEd? – rckrd
ビュー自体を回転させているので、円形のパスで移動する必要があります。これを見て:http://stackoverflow.com/questions/20281265/move-an-image-in-circular-path-in-android – rckrd
あなたの助けをありがとう、私のfauft私はそのような種類の理解していない回転は循環経路における「平行移動」である。 – DeveloperBeginner