Postingan

Menampilkan postingan dari September, 2020

ActionBar title

getActionBar().setTitle(Html.fromHtml("<font color='#78d68e'>Your Title</font>"));

ActionBar subtitle

getActionBar().setSubtitle("Your Subtitle");

ActionBar Backhome

getActionBar().setDisplayHomeAsUpEnabled(true); /* */} @Override public boolean onMenuItemSelected(int featureId, MenuItem item) { int itemId = item.getItemId(); switch (itemId) { case android.R.id.home: finish(); break; } return true;

ActionBar Color

//ActionBar Color ActionBar actionBar = getActionBar(); actionBar.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(Color.parseColor("#191919"))); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {     Window w = MainActivity.this.getWindow();     w.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);     w.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);     w.setStatusBarColor(Color.parseColor("#000000")); }

ActionBar hide

getActionBar().hide();

ActionBar menu

} @Override public boolean onCreateOptionsMenu(Menu menu){ menu.add("Code").setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); menu.add("MoreBlock").setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); return true; } @Override public boolean onOptionsItemSelected(final MenuItem item) { switch (item.getTitle().toString()) { case "Code": showMessage("code clicked"); return true; case "Moreblock": showMessage("moreblock clicked"); return true; default: return super.onOptionsItemSelected(item); }

ActionBar show

getActionBar().show();

ActionBar Background image

ActionBar ab = getActionBar(); ab.setBackgroundDrawable(getDrawable(R.drawable.image_id));

ActionBar back button

getActionBar().setDisplayHomeAsUpEnabled(true); /* */} @Override public boolean onMenuItemSelected(int featureId, MenuItem item) { int itemId = item.getItemId(); switch (itemId) { case android.R.id.home: finish(); break; } return true;

ActionBar Block Capture

getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);

ActionBar Custom

final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); LayoutInflater inflater = (LayoutInflater) this .getSystemService(Context.LAYOUT_INFLATER_SERVICE); //add your own Layout R.layout.your View view = inflater.inflate(R.layout.myview, null); //find widget to be used in onClick ImageView img = (ImageView) view.findViewById(R.id.imageview1); //listener for widget img.setOnClickListener(new View.OnClickListener(){     public void onClick(View v){         // add your  code inside this onClick bracket     } }); actionBar.setCustomView(view); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);

ActionBar Flag no Limit

i f (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {     w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); }

ActionBar Fullscreen

//full screen getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); //unfullscreen getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

ActionBar Hardware Accelerate

getWindow().setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);

ActionBar RGB title

String Int_title = String.format(Locale.US, "#%06X", (0xFFFFFF & Color.argb(120,50,90,10))); //or getActionBar().setTitle(Html.fromHtml("<font color=\\"" + Int_title + "\\">Gabriel</font>"));

ActionBar Screen on

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); //For Remove getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

ActionBar Seticon

getActionBar().setIcon(r.drawable.icon_name);  

ActionBar Shadow

getActionBar().setElevation(0);

ActionBar title Color

getActionBar().setTitle(Html.fromHtml("<font color='#78d68e'>Your Title</font>"));

Animation Blink with Alpha

ObjectAnimator anim = ObjectAnimator.ofFloat(text, "Alpha", 0, 1); anim.setRepeatMode(ObjectAnimator.REVERSE); anim.setRepeatCount(ObjectAnimator.INFINITE); anim.setDuration(700); anim.start();

Animation bounce

ObjectAnimator anim = ObjectAnimator.ofFloat(textView, "ScaleY", 0, 1); anim.setInterpolator(new BounceInterpolator()); anim.setDuration(1000); anim.start();

Animation Colors

ObjectAnimator anim = ObjectAnimator.ofArgb(text, "TextColor", Color.MAGENTA, Color.BLUE, Color.CYAN, Color.GREEN); anim.setDuration(5000); ObjectAnimator animBgr = ObjectAnimator.ofArgb(text, "BackgroundColor", Color.CYAN, Color.GREEN, Color.MAGENTA, Color.BLUE); animBgr.setDuration(5000); AnimatorSet animSet = new AnimatorSet(); animSet.play(anim).with(animBgr); animSet.start();

Animation Fade

//IN final AlphaAnimation fadeIn = new AlphaAnimation(1.0f,0.0f); final AlphaAnimation fadeOut = new AlphaAnimation(0.0f,1.0f); text.startAnimation(fadeIn); text.startAnimation(fadeOut); fadeIn.setDuration(1200); fadeIn.setFillAfter(true); fadeOut.setDuration(1200); fadeOut.setFillAfter(true); fadeOut.setStartOffset(10+fadeIn.getStartOffset()); //OUT final AlphaAnimation fadeIn = new AlphaAnimation(0.0f,1.0f); final AlphaAnimation fadeOut = new AlphaAnimation(1.0f,0.0f); text.startAnimation(fadeIn); text.startAnimation(fadeOut); fadeIn.setDuration(1200); fadeIn.setFillAfter(true); fadeOut.setDuration(1200); fadeOut.setFillAfter(true); fadeOut.setStartOffset(10+fadeIn.getStartOffset());

Animation Fade With Alpha

//IN ObjectAnimator anim = ObjectAnimator.ofFloat(textView, "Alpha", 0, 1); anim.setDuration(5000); anim.start(); //Out ObjectAnimator anim = ObjectAnimator.ofFloat(textView, "Alpha", 1, 0); anim.setDuration(5000); anim.start();

Animation Move

TranslateAnimation translateAnimation = new TranslateAnimation (Animation.RELATIVE_TO_SELF,0f,Animation.RELATIVE_TO_SELF,.85f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0.65f); translateAnimation.setInterpolator(new AccelerateDecelerateInterpolator()); translateAnimation.setDuration(1200); text.startAnimation(translateAnimation);

Animation Rotate

/Anti ClockWise RotateAnimation rotateAnimation = new RotateAnimation(360, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotateAnimation.setInterpolator(new AccelerateInterpolator()); rotateAnimation.setDuration(3000); text.startAnimation(rotateAnimation); //Default RotateAnimation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotateAnimation.setInterpolator(new LinearInterpolator()); rotateAnimation.setDuration(3000); text.startAnimation(rotateAnimation);

Animation Slide Down/Up

//Down ObjectAnimator anim = ObjectAnimator.ofFloat(text, "ScaleY", 0, 1); anim.setDuration(4000); anim.start(); //Up ObjectAnimator anim = ObjectAnimator.ofFloat(text, "ScaleY", 1, 0); anim.setDuration(2000); anim.start();

Animation Slide In/Out

//In ObjectAnimator anim = ObjectAnimator.ofFloat(text, "ScaleX", 1, 0); anim.setDuration(2000); anim.start(); //Out ObjectAnimator anim = ObjectAnimator.ofFloat(text, "ScaleX", 0, 1); anim.setDuration(2000); anim.start();

Animation Text Blink

Animation anim =new AlphaAnimation(0.0f,1.0f); anim.setDuration(50); anim.setStartOffset(20); anim.setRepeatMode(Animation.REVERSE); anim.setRepeatCount(Animation.INFINITE); text.startAnimation(anim);

Animation TranslateXY

//Animation From XML tranlate Animation animation = new TranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta); animation.setDuration(1500); animation.setFillAfter(true); view.startAnimation(animation);

Animation Transtition Animation

/*this will go in button click, activity start, or whatever*/ android.transition.TransitionManager.beginDelayedTransition(linear1,makeFadeTransition()); toggleVisibility(imageview1,imageview2,imageview3,imageview4); android.transition.TransitionManager.beginDelayedTransition(linear1,makeSlideTransition()); toggleVisibility(imageview1,imageview2,imageview3,imageview4); android.transition.TransitionManager.beginDelayedTransition(linear1,makeExplodeTransition()); toggleVisibility(imageview1,imageview2,imageview3,imageview4); /*This stays at the bottom of all code in onCreate*/ } private android.transition.Fade makeFadeTransition(){ android.transition.Fade fade = new android.transition.Fade(); fade.setDuration(2000); fade.setInterpolator(new AnticipateInterpolator()); return fade; } private android.transition.Slide makeSlideTransition(){ android.transition.Slide slide = new android.transition.Slide(); slide.setSlideEdge(Gravity.TOP); slide.setInterpolator(new BounceInterpolator()); slide.s...

Animation ZoomIn/ZoomOut

//IN ScaleAnimation scaleAnimation = new ScaleAnimation(1f,4f,1f,4f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); scaleAnimation.setInterpolator(new LinearInterpolator()); scaleAnimation.setDuration(1800); text.startAnimation(scaleAnimation); //Out ScaleAnimation scaleAnimation = new ScaleAnimation(1f,0.5f,1f,.50f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); scaleAnimation.setInterpolator(new AccelerateDecelerateInterpolator()); scaleAnimation.setDuration(1800); text.startAnimation(scaleAnimation);

App list with icon (launch app)

Intent startupIntent = new Intent(Intent.ACTION_MAIN);  startupIntent.addCategory(Intent.CATEGORY_LAUNCHER);   final android.content.pm.PackageManager pm = getPackageManager();  List<android.content.pm.ResolveInfo> activities = pm.queryIntentActivities(startupIntent,0);    Collections.sort(activities, new Comparator<android.content.pm.ResolveInfo>() {   public int compare(android.content.pm.ResolveInfo a, android.content.pm.ResolveInfo b) {   android.content.pm.PackageManager pm = getPackageManager();   return String.CASE_INSENSITIVE_ORDER.compare(   a.loadLabel(pm).toString(),   b.loadLabel(pm).toString());   }   });    ArrayAdapter<android.content.pm.ResolveInfo> adapter = new ArrayAdapter<android.content.pm.ResolveInfo>(   this, android.R.layout.simple_list_item_1, activities) {   pub...

App list with icon (Uninstall app)

Intent startupIntent = new Intent(Intent.ACTION_MAIN);  startupIntent.addCategory(Intent.CATEGORY_LAUNCHER);   final android.content.pm.PackageManager pm = getPackageManager();  List<android.content.pm.ResolveInfo> activities = pm.queryIntentActivities(startupIntent,0);    Collections.sort(activities, new Comparator<android.content.pm.ResolveInfo>() {   public int compare(android.content.pm.ResolveInfo a, android.content.pm.ResolveInfo b) {   android.content.pm.PackageManager pm = getPackageManager();   return String.CASE_INSENSITIVE_ORDER.compare(   a.loadLabel(pm).toString(),   b.loadLabel(pm).toString());   }   });    ArrayAdapter<android.content.pm.ResolveInfo> adapter = new ArrayAdapter<android.content.pm.ResolveInfo>(   this, android.R.layout.simple_list_item_1, activities) {   pub...

App list without icon (launch app)

Intent startupIntent = new Intent(Intent.ACTION_MAIN);  startupIntent.addCategory(Intent.CATEGORY_LAUNCHER);   final android.content.pm.PackageManager pm = getPackageManager();  List<android.content.pm.ResolveInfo> activities = pm.queryIntentActivities(startupIntent,0);    Collections.sort(activities, new Comparator<android.content.pm.ResolveInfo>() {   public int compare(android.content.pm.ResolveInfo a, android.content.pm.ResolveInfo b) {   android.content.pm.PackageManager pm = getPackageManager();   return String.CASE_INSENSITIVE_ORDER.compare(   a.loadLabel(pm).toString(),   b.loadLabel(pm).toString());   }   });    ArrayAdapter<android.content.pm.ResolveInfo> adapter = new ArrayAdapter<android.content.pm.ResolveInfo>(   this, android.R.layout.simple_list_item_1, activities) {   pub...

App list without icon (Uninstall app)

Intent startupIntent = new Intent(Intent.ACTION_MAIN);  startupIntent.addCategory(Intent.CATEGORY_LAUNCHER);   final android.content.pm.PackageManager pm = getPackageManager();  List<android.content.pm.ResolveInfo> activities = pm.queryIntentActivities(startupIntent,0);    Collections.sort(activities, new Comparator<android.content.pm.ResolveInfo>() {   public int compare(android.content.pm.ResolveInfo a, android.content.pm.ResolveInfo b) {   android.content.pm.PackageManager pm = getPackageManager();   return String.CASE_INSENSITIVE_ORDER.compare(   a.loadLabel(pm).toString(),   b.loadLabel(pm).toString());   }   });    ArrayAdapter<android.content.pm.ResolveInfo> adapter = new ArrayAdapter<android.content.pm.ResolveInfo>(   this, android.R.layout.simple_list_item_1, activities) {   pub...

Background AutoColor

color1 = 0xffffffff; anim = ObjectAnimator.ofInt(linear1, "backgroundColor", color1); anim.setEvaluator(new ArgbEvaluator()); anim.setDuration(1000); new Thread() { public void run() { while(true) { try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } runOnUiThread(new Runnable() { public void run() { red2 = (int)(java.lang.Math.random() * 128 + 127); green2 = (int)(java.lang.Math.random() * 128 + 127); blue2 = (int)(java.lang.Math.random() * 128 + 127); color2 = 0xff << 24 | (red2 << 16) | (green2 << 8) | blue2; anim.setIntValues(color1, color2); anim.start(); color1 = color2; } }); } } }.start(); } public int color1, color2, red1, red2, blue1, blue2, green1, green2; ObjectAnimator anim; {

Background RGB Color

linear1.setBackgroundColor(Color.rgb(212,98,151));

Background HexColor

linear1.setBackgroundColor(Color.parseColor("#000000"));

Battery Level code

BatteryManager bm = (BatteryManager)getSystemService(BATTERY_SERVICE); int batLevel = bm.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY); textview1.setText(Integer.toString(batLevel));

BroadCast Battery Charging Status

//onCreate IntentFilter iFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); getApplicationContext().registerReceiver(mBroadcastReceiver,iFilter); private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Toast.makeText(getApplicationContext(), "Received", Toast.LENGTH_SHORT).show(); int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS,-1); String statusString = ""; if(status == BatteryManager.BATTERY_STATUS_UNKNOWN){ statusString = "UNKNOWN"; }else if(status == BatteryManager.BATTERY_STATUS_CHARGING){ statusString = "CHARGING"; }else if(status == BatteryManager.BATTERY_STATUS_DISCHARGING){ statusString = "DISCHARGING"; }else if (status == BatteryManager.BATTERY_STATUS_NOT_CHARGING){ statusString = "NOT CHARGING"; }else if (status == BatteryManager.BATTERY_STATUS_FULL){ statusString = "FULL"; } textview1.setText("Batter...

BroadCast Battery Healt

//onCreate IntentFilter iFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); getApplicationContext().registerReceiver(mBroadcastReceiver,iFilter); private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Toast.makeText(getApplicationContext(), "Received", Toast.LENGTH_SHORT).show(); int health = intent.getIntExtra(BatteryManager.EXTRA_HEALTH,0); String healthString = ""; // Determine the battery health from return integer value if(health == BatteryManager.BATTERY_HEALTH_COLD){    healthString = "COLD"; }else if (health == BatteryManager.BATTERY_HEALTH_DEAD){    healthString = "DEAD"; }else if (health == BatteryManager.BATTERY_HEALTH_GOOD){    healthString = "GOOD"; }else if (health == BatteryManager.BATTERY_HEALTH_OVERHEAT){    healthString = "OVER HEAT"; }else if (health == BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE){    healthString = ...

BroadCast Battery Temperature

//OnCreate IntentFilter iFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); getApplicationContext().registerReceiver(mBroadcastReceiver,iFilter); private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { float temperature = (float)(intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE,0))/10; textview1.setText("Battery Temperature " + temperature +" "+ (char) 0x00B0 +"C"); } };

BroadCast Battery Voltage

//InCreate IntentFilter iFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); getApplicationContext().registerReceiver(mBroadcastReceiver,iFilter); private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Toast.makeText(getApplicationContext(), "Received", Toast.LENGTH_SHORT).show(); int voltage = intent.getIntExtra(BatteryManager.EXTRA_VOLTAGE,0); double volt =  voltage * 0.0 java.text.DecimalFormat newFormat = new java.text.DecimalFormat("#.#"); double oneDecimalVolt =  Double.valueOf(newFormat.format(volt)); textview1.setText("Battery Voltage"); textview1.setText(textview1.getText() +" Millivolts : " + voltage); textview1.setText(textview1.getText() + " Volt : " + oneDecimalVolt); } };

BroadCast Battery Charging state

//onCreate IntentFilter iFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); getApplicationContext().registerReceiver(mBroadcastReceiver,iFilter); private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Toast.makeText(getApplicationContext(), "Received", Toast.LENGTH_SHORT).show(); int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS,-1); boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL; if(isCharging){ textview1.setText("Charging : Yes."); int chargePlug = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED,-1); boolean usbCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_USB; if(usbCharge){ textview1.setText(textview1.getText()+" USB Charging"); } boolean acCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_AC; if(acCharge){ textview1.setText(textview1.getText()+" AC Charging"); ...

ClipBoard Monitor ClipBoard

((android.content.ClipboardManager) getSystemService(getApplicationContext().CLIPBOARD_SERVICE)).addPrimaryClipChangedListener(new android.content.ClipboardManager.OnPrimaryClipChangedListener() { public void onPrimaryClipChanged() { showMessage("Haha"); edittext1.setText("Copy!"); } });

Cara pembuatan Apps paling Populer

TextInputLayout in Sketchware

Create Stopwatch App in Android using Sketchware

How to enable download in webview in Sketchware apps?

How to find and​ highlight a word in a text field in Sketchware?

A Flash Light App in Sketchware

Create Stopwatch App in Android using Sketchware

Code for implementing Notifications in Sketchware

How to share an image from Drawable folder?

Code for implementing Notifications in Sketchware

Firebase Login/Register with email verification