nine-patch
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
Android: 9-patch repeat pattern instead of stretching
I think it’s not possible using 9-Patch to make repeated patterns (only stretching certain area), perhaps you could find more about it in official documentation
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
Creating & Using 9-patch images in Android
The SDK and Android Studio both ship with the “Draw 9-patch” tool (“draw9patch” in the SDK tools folder) which is a simple editor. Here is a nicer one which is also open source. It has a simple but clever default image. The official documentation has improved over the years. In summary, nine patch images’ most … 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
How to change the spinner background in Android?
You can set the spinners background color in xml like this: android:background=”YOUR_HEX_COLOR_CODE” and if you use the drop down menu with you spinner you can set its background color like this: android:popupBackground=”YOUR_HEX_COLOR_CODE”