下面列出了android.widget.FrameLayout#getRight ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void showRevealEditText(FrameLayout view) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
int cx = view.getRight() - 30;
int cy = view.getBottom() - 60;
int finalRadius = Math.max(view.getWidth(), view.getHeight());
Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius);
view.setVisibility(View.VISIBLE);
isEditTextVisible = true;
anim.start();
} else {
view.setVisibility(View.VISIBLE);
isEditTextVisible = true;
}
}
private void hideReavelEditText(final FrameLayout view) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
int cx = view.getRight() - 30;
int cy = view.getBottom() - 60;
int initialRadius = view.getWidth();
Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, initialRadius, 0);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
view.setVisibility(View.INVISIBLE);
}
});
isEditTextVisible = false;
anim.start();
} else {
view.setVisibility(View.INVISIBLE);
isEditTextVisible = false;
}
}
/***
* Hide the searchbox using the circle animation. Can be called regardless of result list length
* @param activity Activity
*/
public void hideCircularly(Activity activity){
Display display = activity.getWindowManager().getDefaultDisplay();
Point size = new Point();
final FrameLayout layout = (FrameLayout) activity.getWindow().getDecorView()
.findViewById(android.R.id.content);
RelativeLayout root = (RelativeLayout) findViewById(R.id.search_root);
display.getSize(size);
Resources r = getResources();
float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 96,
r.getDisplayMetrics());
int cx = layout.getLeft() + layout.getRight();
int cy = layout.getTop();
int finalRadius = (int) Math.max(layout.getWidth()*1.5, px);
SupportAnimator animator = ViewAnimationUtils.createCircularReveal(
root, cx, cy, 0, finalRadius);
animator.setInterpolator(new ReverseInterpolator());
animator.setDuration(250);
animator.start();
animator.addListener(new SupportAnimator.AnimatorListener(){
@Override
public void onAnimationStart() {
}
@Override
public void onAnimationEnd() {
setVisibility(View.GONE);
}
@Override
public void onAnimationCancel() {
}
@Override
public void onAnimationRepeat() {
}
});
}
private void revealFrom(float x, float y, Activity a, SearchBox s) {
FrameLayout layout = (FrameLayout) a.getWindow().getDecorView()
.findViewById(android.R.id.content);
RelativeLayout root = (RelativeLayout) s.findViewById(R.id.search_root);
Resources r = getResources();
float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 96,
r.getDisplayMetrics());
int cx = layout.getLeft() + layout.getRight();
int cy = layout.getTop();
int finalRadius = (int) Math.max(layout.getWidth(), px);
SupportAnimator animator = ViewAnimationUtils.createCircularReveal(
root, cx, cy, 0, finalRadius);
animator.setInterpolator(new AccelerateDecelerateInterpolator());
animator.setDuration(500);
animator.addListener(new SupportAnimator.AnimatorListener(){
@Override
public void onAnimationCancel() {
}
@Override
public void onAnimationEnd() {
toggleSearch();
}
@Override
public void onAnimationRepeat() {
}
@Override
public void onAnimationStart() {
}
});
animator.start();
}
/***
* Hide the searchbox using the circle animation. Can be called regardless of result list length
* @param activity
*/
public void hideCircularly(Activity activity){
Display display = activity.getWindowManager().getDefaultDisplay();
Point size = new Point();
final FrameLayout layout = (FrameLayout) activity.getWindow().getDecorView()
.findViewById(android.R.id.content);
RelativeLayout root = (RelativeLayout) findViewById(R.id.search_root);
display.getSize(size);
Resources r = getResources();
float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 96,
r.getDisplayMetrics());
int cx = layout.getLeft() + layout.getRight();
int cy = layout.getTop();
int finalRadius = (int) Math.max(layout.getWidth()*1.5, px);
SupportAnimator animator = ViewAnimationUtils.createCircularReveal(
root, cx, cy, 0, finalRadius);
animator.setInterpolator(new ReverseInterpolator());
animator.setDuration(500);
animator.start();
animator.addListener(new SupportAnimator.AnimatorListener(){
@Override
public void onAnimationStart() {
}
@Override
public void onAnimationEnd() {
setVisibility(View.GONE);
}
@Override
public void onAnimationCancel() {
}
@Override
public void onAnimationRepeat() {
}
});
}
private void revealFrom(float x, float y, Activity a, SearchBox s) {
Display display = a.getWindowManager().getDefaultDisplay();
Point size = new Point();
FrameLayout layout = (FrameLayout) a.getWindow().getDecorView()
.findViewById(android.R.id.content);
RelativeLayout root = (RelativeLayout) s.findViewById(R.id.search_root);
display.getSize(size);
Resources r = getResources();
float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 96,
r.getDisplayMetrics());
int cx = layout.getLeft() + layout.getRight();
int cy = layout.getTop();
int finalRadius = (int) Math.max(layout.getWidth(), px);
SupportAnimator animator = ViewAnimationUtils.createCircularReveal(
root, cx, cy, 0, finalRadius);
animator.setInterpolator(new AccelerateDecelerateInterpolator());
animator.setDuration(500);
animator.addListener(new SupportAnimator.AnimatorListener(){
@Override
public void onAnimationCancel() {
}
@Override
public void onAnimationEnd() {
toggleSearch();
}
@Override
public void onAnimationRepeat() {
}
@Override
public void onAnimationStart() {
}
});
animator.start();
}