Remove padding around buttons in Android
<Button android:minHeight="0dp" android:minWidth="0dp" ...
References
https://stackoverflow.com/questions/17960599/how-to-remove-padding-around-buttons-in-android
<Button android:minHeight="0dp" android:minWidth="0dp" ...
References
https://stackoverflow.com/questions/17960599/how-to-remove-padding-around-buttons-in-android
Just use a LinearLayout and pretend it’s a Button – setting background and clickable is the key:
<LinearLayout android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@android:drawable/btn_default" android:clickable="true" android:orientation="horizontal" > <ImageView android:id="@+id/img" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginLeft="5dp" android:src="@drawable/image" /> <TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_margin="5dp" android:text="Do stuff" /> </LinearLayout>
References
https://stackoverflow.com/questions/1532876/android-combining-text-image-on-a-button-or-imagebutton
AndroidManifest.xml
<activity android:name=".MainActivity" android:windowSoftInputMode="stateHidden" />
References
https://stackoverflow.com/questions/10611833/how-to-disable-keypad-popup-when-on-edittext
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <solid android:color="#666666" /> <size android:width="8dp" android:height="8dp" /> </shape>
<ImageView android:id="@+id/imageViewStep2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginEnd="4dp" android:layout_marginRight="4dp" android:background="@drawable/ic_stepper" android:contentDescription="@string/step_2" />
Drawable background = imageViewStep1.getBackground(); if (background instanceof ShapeDrawable) { // cast to 'ShapeDrawable' ShapeDrawable shapeDrawable = (ShapeDrawable) background; shapeDrawable.getPaint().setColor(ContextCompat.getColor(this, R.color.md_blue_500)); } else if (background instanceof GradientDrawable) { // cast to 'GradientDrawable' GradientDrawable gradientDrawable = (GradientDrawable) background; gradientDrawable.setColor(ContextCompat.getColor(this, R.color.md_blue_500)); } else if (background instanceof ColorDrawable) { // alpha value may need to be set again after this call ColorDrawable colorDrawable = (ColorDrawable) background; colorDrawable.setColor(ContextCompat.getColor(this, R.color.md_blue_500)); }
References
https://stackoverflow.com/questions/17823451/set-android-shape-color-programmatically
public final static boolean isValidEmail(CharSequence target) { if (target == null) return false; return android.util.Patterns.EMAIL_ADDRESS.matcher(target).matches(); }
References
https://stackoverflow.com/questions/9355899/android-email-edittext-validation
In this method just current activity receive this event
Add to android Manifest
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
In your activity, create a Broadcast Receiver:
private BroadcastReceiver networkStateReceiver=new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = manager.getActiveNetworkInfo(); doSomethingOnNetworkChange(ni); } };
@Override public void onResume() { super.onResume(); registerReceiver(networkStateReceiver, new IntentFilter(android.net.ConnectivityManager.CONNECTIVITY_ACTION)); } @Override public void onPause() { unregisterReceiver(networkStateReceiver); super.onPause(); }
References
https://stackoverflow.com/questions/6169059/android-event-for-internet-connectivity-state-change
download TWRP image then go to download folder
adb reboot bootloader fastboot devices # just for check
fastboot flash recovery twrp_3.0.2_mate7_6.0.img
fastboot reboot
download zip file of SuperSu and put it on root folder of Phone SD card
adb reboot recovery
install zip
References
http://forum.supersu.com/topic/908/huawei-phone-general-guide-huawei-root
http://www.droidviews.com/how-to-boot-android-devices-in-fastboot-download-bootloader-or-recovery-mode/
https://android.gadgethacks.com/how-to/know-your-android-tools-what-is-fastboot-do-you-use-it-0155640/
class WordBreakTransformationMethod extends ReplacementTransformationMethod { private static WordBreakTransformationMethod instance; private WordBreakTransformationMethod() {} public static WordBreakTransformationMethod getInstance() { if (instance == null) { instance = new WordBreakTransformationMethod(); } return instance; } private static char[] dash = new char[] {'-', '\u2011'}; private static char[] space = new char[] {' ', '\u00A0'}; private static char[] original = new char[] {dash[0], space[0]}; private static char[] replacement = new char[] {dash[1], space[1]}; @Override protected char[] getOriginal() { return original; } @Override protected char[] getReplacement() { return replacement; } }
myEditText.setTransformationMethod(WordBreakTransformationMethod.getInstance());
References
https://stackoverflow.com/questions/22289161/word-wrap-break-word-in-edittext
For < Android Nougat:
myTextView.setText(Html.fromHtml(“<h2>Title</h2><br><p>Description here</p>”));
For >= Android Nougat:
myTextView.setText(Html.fromHtml("<h2>Title</h2><br><p>Description here</p>", Html.FROM_HTML_MODE_COMPACT));
To distinguish between Android versions use Build.VERSION.SDK_INT >= Build.VERSION_CODES.N.
References
https://stackoverflow.com/questions/2116162/how-to-display-html-in-textview
Runnable:
private final int interval = 1000; // 1 Second private Handler handler = new Handler(); private Runnable runnable = new Runnable(){ public void run() { Toast.makeText(MyActivity.this, "C'Mom no hands!", Toast.LENGTH_SHORT).show(); } }; ... handler.postAtTime(runnable, System.currentTimeMillis()+interval); handler.postDelayed(runnable, interval);
Message:
private final int EVENT1 = 1; private Handler handler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case Event1: Toast.makeText(MyActivity.this, "Event 1", Toast.LENGTH_SHORT).show(); break; default: Toast.makeText(MyActivity.this, "Unhandled", Toast.LENGTH_SHORT).show(); break; } } }; ... Message msg = handler.obtainMessage(EVENT1); handler.sendMessageAtTime(msg, System.currentTimeMillis()+interval); handler.sendMessageDelayed(msg, interval);
References
https://stackoverflow.com/questions/1877417/how-to-set-a-timer-in-android