public class MainActivity extends AppCompatActivity {
TextView text_view;
Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
text_view = (TextView)findViewById(R.id.text_view);
button = (Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
toggleInformationView();
}
});
}
private void toggleInformationView() {
int cx = (text_view.getWidth()) / 2;
int cy = (text_view.getHeight()) / 2;
float radius = Math.max(text_view.getWidth(), text_view.getHeight()) * 2.0f;
if (text_view.getVisibility() == View.INVISIBLE) {
text_view.setVisibility(View.VISIBLE);
ViewAnimationUtils.createCircularReveal(text_view, cx, cy, 0, radius).start();
} else {
text_view.setVisibility(View.INVISIBLE);
Animator reveal = ViewAnimationUtils.createCircularReveal(
text_view, cx, cy, radius, 0);
reveal.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
text_view.setVisibility(View.INVISIBLE);
}
});
reveal.start();
}
}
}
'android code' 카테고리의 다른 글
SparseArray for 문 돌리는 법 (0) | 2016.07.27 |
---|---|
벡터 드로어블 생성 (0) | 2016.06.01 |
RippleDrawable (0) | 2016.05.31 |
[Android] ListView에서 클릭이 제대로 인식되지 않는 문제 (3) | 2016.05.31 |
안드로이드에서 파일 복사하기 (0) | 2016.03.07 |