TanG
TanG

Reputation: 5

Trying to make a button move in a circle android studio

I am trying to make a button move in a circle in portrait mode and in landscape i am trying to hide the button. i used this in main activity. In landscape mode i used the the command android: visibility = "gone" but didnt really work the outline of button can be seen moving. How do i solve this issue

Main activity

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final Button but1 = (Button)findViewById(R.id.but1);
    RotateAnimation rC = new RotateAnimation(360,0,Animation.RELATIVE_TO_PARENT,0.2f,Animation.RELATIVE_TO_PARENT, 0.2f);
    rC.setDuration(1000);
    rC.setInterpolator(new LinearInterpolator());
    rC.setRepeatMode(Animation.RESTART);
    rC.setRepeatCount(Animation.INFINITE);
    but1.startAnimation(rC);
}

Upvotes: 0

Views: 81

Answers (1)

i30mb1
i30mb1

Reputation: 4786

After rotation method onCreate calling again, you should check if you are in landscape mode and do not run the animation for button, that is all

Upvotes: 1

Related Questions