For TextView android

<TextView
// some attributes
android:shadowColor="#YourHexColorHere"
android:shadowDx="10"
android:shadowDy="10"
android:shadowRadius="7"/>

// set font style
// same as this article: https://davidng94.wordpress.com/2016/01/02/use-your-custom-font-in-android/
Typeface typeFace = Typeface.createFromAsset(
getAssets(), "YourFontNameHere");
textView.setTypeface(typeFace);

// set gradient color
Shader shader = new LinearGradient(
0, 0, 0, textView.getTextSize(),
Color.BLUE, Color.RED,
Shader.TileMode.CLAMP);
textView.getPaint().getShader(shader);
// set pattern background
Bitmap bmp = BitmapFactory.decodeResource(
getResources(),
R.drawable.yourImageInDrawableHere);
Shader shader = new BitmapShader(
bmp,
Shader.TileMode.REPEAT,
Shader.TileMode.REPEAT);
textView.getPaint().getShader(shader);

Debugging Android application via a wireless connection?

Sometime you don’t want to use USB cable (directly connect your device to computer) or you have problems with USB ports on your computer or something else.

Today, i finally found a really good solution to do this, it’s very simple. Read carefully all following steps below:

Step 1: Connect your device to computer via USB cable, make sure that “debugging mode” is activated. android device and computer must be connected to the same WIFI network (if you don’t know how to enable debugging mode,please search by google with keyword: “enable debugging mode in android”).
Step 2: Open CMD and run this command: adb tcpip 5555
Step 3: Run this command: adb shell netcfg to get your android device’s IP address.
Step 4: Continue to run command adb connect <IP_ADDRESS>:5555 and wait for a couple of seconds and then disconnect USB connection. Now you can properly run application in Android studio/eclipse, your device’s name still listed on the device choosing dialog, that really amazing!
When done, run this command: adb -s <IP_ADDRESS>:5555 usb to rollback to the previous setting (debugging via USB directly option).

 

Cheers
Huy N
http://mhuy.xyz

How to change screen orientation programmatically?

&lt;br /&gt;Configuration config = getResources().getConfiguration();

android.app.FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();

switch(config.orientation) {
case Configuration.ORIENTATION_LANDSCAPE:
// Device is now in landscape mode.
MyLandscapeFragment fragment = new MyLandscapeFragment();
fragmentTransaction.replace(android.R.id.fragmentLayoutId, fragment);
break;
default:
// Device is now in portrait mode.
MyPortraitFragment fragment = new MyPortraitFragment();
fragmentTransaction.replace(android.R.id.fragmentLayoutId, fragment);
break;
}
fragmentTransaction.commit();

finally go to android manifest and make some changes for specified activity:

<activity android:name=".MyActivity" ... android:configChanges="orientation">