Java Code Examples for android.widget.RelativeLayout.getLeft()

The following are Jave code examples for showing how to use getLeft() of the android.widget.RelativeLayout class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: betterHotels   File: SnackbarBehavior.java   Source Code and License Vote up 5 votes
@Override
    public boolean onDependentViewChanged(CoordinatorLayout parent, RelativeLayout child, View dependency) {
        Toast.makeText(context, "changed", Toast.LENGTH_SHORT).show();
        if ((dependency.getLeft() < child.getLeft() && child.getLeft() < dependency.getRight()) ||
                (dependency.getLeft() < child.getRight() && child.getRight() < dependency.getRight())) {
            float translationY = Math.min(0, dependency.getTranslationY() - dependency.getHeight());
            child.setTranslationY(-400);
//            value = value - 100;
//            TranslateAnimation translateAnimation = new TranslateAnimation(0, 0,0, value);
//            translateAnimation.setFillAfter(true);
//            child.startAnimation(translateAnimation);
        }
        return true;
    }
 
Example 2
Project: music_player   File: MainActivity.java   Source Code and License Vote up 4 votes
public void animation_change_color(int Int) {
    ImageView play_now_back_color = (ImageView) findViewById(R.id.play_now_back_color);
    if (cx == 0) {
        FloatingActionButton play_or_pause = (FloatingActionButton) findViewById(R.id.play_or_pause);
        RelativeLayout seekbar_layout = (RelativeLayout) findViewById(R.id.seekbar_layout);
        RelativeLayout control_layout = (RelativeLayout) findViewById(R.id.control_layout);
        cx = play_or_pause.getLeft() + control_layout.getLeft() + play_or_pause.getWidth() / 2;
        cy = control_layout.getTop() - seekbar_layout.getTop() + play_or_pause.getTop() + play_or_pause.getHeight() / 2;
        finalRadius = Math.max(play_now_back_color.getWidth(), play_now_back_color.getHeight());
    }
    final int Int1 = Int;
    final RelativeLayout activity_now_play = (RelativeLayout) findViewById(R.id.activity_now_play);
    if (cx != 0) {
        Animator anim = ViewAnimationUtils.createCircularReveal(play_now_back_color, cx, cy, 0, finalRadius);
        play_now_back_color.setBackgroundColor(Int);
        anim.setDuration(500);
        anim.start();
        anim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                activity_now_play.setBackgroundColor(Int1);
            }
        });
    }else{
        activity_now_play.setBackgroundColor(Int1);
    }
    TextView now_on_play_text = (TextView) findViewById(R.id.now_on_play_text);
    now_on_play_text.setTextColor(Int);
    //lrcview字体颜色

    //歌词背景颜色
    if(Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
        View bottom = findViewById(R.id.gradient_bottom);
        View top = findViewById(R.id.gradient_top);
        View gradient = findViewById(R.id.gradient);
        top.setBackground(
                ScrimUtil.makeCubicGradientScrimDrawable(Int1, //颜色
                        8, //渐变层数
                        Gravity.TOP)); //起始方向
        bottom.setBackground(
                ScrimUtil.makeCubicGradientScrimDrawable(Int1, //颜色
                        8, //渐变层数
                        Gravity.BOTTOM)); //起始方向
        gradient.setBackground(
                ScrimUtil.makeCubicGradientScrimDrawable(Int1, //颜色
                        8, //渐变层数
                        Gravity.BOTTOM)); //起始方向
    }
}