How to return to default style on EditText if I apply a background?

First, before you call setBackgroundResource with your own ninepatch, store the original background of the EditText, like this: Drawable originalDrawable = myEditText.getBackground(); Then, if the user entered the wrong data, you can set your red border ninepatch: myEditText.setBackgroundResource(R.drawable.edittext_red); And later, when you want to restore the look of the EditText, use the stored drawable: myEditText.setBackgroundDrawable(originalDrawable); … Read more

Create a NinePatch/NinePatchDrawable in runtime

getNinePatchChunk works just fine. It returned null because you were giving Bitmap a “source” ninepatch. It needs a “compiled” ninepatch image. There are two types of ninepatch file formats in the Android world (“source” and “compiled”). The source version is where you add the 1px transparency border everywhere– when you compile your app into a … Read more

How to create android spinner without down triangle on the right side of the widget

This is quite an old question, but I think still relevant, so here’s my answer: Simplest Method lencinhaus answer is correct. It works, but it can be done in an even simpler way: Just add another background to it. The example below uses the standard Button background for a more homogeneous look-and-feel: <Spinner android:id=”@+id/my_spinner” android:layout_width=”wrap_content” … Read more

9-patch image error in Android

I have encountered with same problem on Android Studio: AAPT out(943142208) : No Delegate set : lost message:Done AAPT err(943142208): ERROR: 9-patch image /Users/cartman/Github/UteacherAndroid/RefactorDemo/app/src/main/res/drawable-xxhdpi/nav_shabow.9.png malformed. AAPT err(943142208): Frame pixels must be either solid or transparent (not intermediate alphas). AAPT err(943142208): Found at pixel #1 along left edge. This is how I resolved it: Open draw9patch … Read more

tech