Posts

Get Percent of the Number (98%)

 Get Percent of the Number By achieving the percentage of a number, divide the numbers and multiply it by 100. Example: Presidential Votes Bongbong Marcos gathered around 31,000,000 votes while his counterpart gathered only 14,000,000 and the people voted is more than 65,000,000. Bongbong Marcos - 31,000,000 Total Voters -  65,000,000 All you have to do is divide the two numbers (BBM votes and total votes) and multiply it by 100 to get the percentage of 100. 31,000,000 ÷ 65,000,000 = 0.476923076 0.476923076 × 100 = 47% Bongbong Marcos won the Presidential Election with 47% majority vote.

Number with Comma (9,999)

 Number with Comma (9,999) It's very easy if you're using Sketchware Pro. Follow this: Just go to Blocks then Operator and then scroll down and choose toDecimalFormat and then type this ###,### inside the box of toDecimalFormat while the circle is the number value If you're not using Sketchware Pro. Follow this: Go to Activity and put this code textview1.setText(new DecimalFormat("###,###").format(25)); ###,### - To make the number format like 999,999,999,999 25 - Is the value

onTouchListener Hover Effect

 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;             }         });

Status Bar Text Visibility

 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

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));