Status Bar Text Visibility The text of status bar can't see when you set your status bar color to white, so to fix it you only need this one code in your Activity. It will automatically make your status bar text visible. Codes: linear1.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
Get X, Y Position of Layout Detect the position of layout by following the steps. Step 1: Create two number variables, I'll name it x and y Step 2: Put this code: float x = Math.round(textview1.getX()); float y = Math.round(textview1.getY()); If you want to set the X, Y position of Layout follow this additional step. Step 3: textview1.setX((float)200)); textview1.setY((float)50));
onTouchListener Hover Effect Hover effect when you touch the view and release it. Like when I touch it the button the button text will be "TOUCHING..." and after I release it it will be "Touched, done". Codes: button1.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_DOWN){ // PUT YOUR CODE HERE WHEN TOUCHING, ILL PUT MINE button1.setText("TOUCHING..."); } if(event.getAction() == MotionEvent.ACTION_UP){ // PUT YOUR SECOND CODE HERE WHEN RELEASED button1.setText("TOUCHED"); } return false; } });
Comments
Post a Comment