nine-patch

Drawing Nine Patch onto Canvas (Android)

好久不见. 提交于 2019-11-30 10:25:37
问题 I'm trying to draw a nine patch onto a Canvas object on the Android. What seems strange is that although I generated my nine patch using the draw9patch tool, the constructor for NinePatch requires an additional byte array called the "chunk" to construct the nine patch. Why isn't this simpler? What is the "chunk"? And if you have done this yourself, how did you go about it? Any help appreciated. 回答1: You can easily do it this way: // Load the image as a NinePatch drawable NinePatchDrawable npd

?android:attr/selectableItemBackground with another existing background

拟墨画扇 提交于 2019-11-30 07:14:48
I have a 9patch set as the background of my layout. However I still want to provide touch feedback by using the selectableItemBackground attr. I've tried using a <layer-list> with the 9patch and selectableItemBackground as the android:drawable of the second <item> , however that did not work. I could also try making a selector and overlay the gradient drawable android uses for selectableItemBackground in list_selector_background_pressed.xml with a <layer-list> . But in 4.4 KitKat the selected background color is actually gray instead of blue in JellyBeans, so I can't really hardcode it :(

Bad 'Patches' in 9-Patch File

与世无争的帅哥 提交于 2019-11-30 05:56:58
I'm attempting to use the Draw9Patch tool from the Android SDK, but immediately upon opening my image with Draw9Patch it shows all of my image area as a 'Bad Patch.' I manually drew in the lines that define the stretchable areas, however I am unsure if this will work properly. Could someone explain why this specific image is not a 'good patch'? Other Stackoverflow answers to this question do not seem to correlate to my problem or I am not understanding them. Old, but I had the same question. The "bad patch" thing is definitely confusing, but won't stop your drawable from working. The dev sites

Drawing Nine Patch onto Canvas (Android)

只谈情不闲聊 提交于 2019-11-29 20:19:43
I'm trying to draw a nine patch onto a Canvas object on the Android. What seems strange is that although I generated my nine patch using the draw9patch tool, the constructor for NinePatch requires an additional byte array called the "chunk" to construct the nine patch. Why isn't this simpler? What is the "chunk"? And if you have done this yourself, how did you go about it? Any help appreciated. Mark B You can easily do it this way: // Load the image as a NinePatch drawable NinePatchDrawable npd = (NinePatchDrawable)Resources.getDrawable(R.drawable.my_nine_patch); // Set its bound where you

?android:attr/selectableItemBackground with another existing background

ぃ、小莉子 提交于 2019-11-29 09:19:03
问题 I have a 9patch set as the background of my layout. However I still want to provide touch feedback by using the selectableItemBackground attr. I've tried using a <layer-list> with the 9patch and selectableItemBackground as the android:drawable of the second <item> , however that did not work. I could also try making a selector and overlay the gradient drawable android uses for selectableItemBackground in list_selector_background_pressed.xml with a <layer-list> . But in 4.4 KitKat the selected

Loading nine-patch image as a Libgdx Scene2d Button background looks awful

你。 提交于 2019-11-29 07:49:23
I'm trying to use a Nine Patch as a background for a Libgdx Scene2d UI button. It is loading, buts it is really ugly. I can see the "meta-data" pixels, and its being stretched as if it were just a regular image (the text on the button is "Continue"): I'm loading the .9.png files directly into a (libgdx) NinePatchDrawable via a (libgdx) NinePatch like this: this.dialogButtonUp = new NinePatchDrawable( new NinePatch(new Texture(Gdx.files.internal("data/button-round.9.png")))); this.dialogButtonDown = new NinePatchDrawable( new NinePatch(new Texture(Gdx.files.internal("data/button-round-down.9

9 Patch image where center is 1:1

ぃ、小莉子 提交于 2019-11-29 06:12:55
I want to create a splash screen on Android with a small logo in the middle, but the logo is streched on larger devices. I thought I could use a 9 patch image, but it seems a 9 patch image works inversed to what I try to reach. This is the logo that has to be in the middle. This is what I get when I set the image as a 9 patch. The center is stretched out and the corners are intact. I need to opposite. I need a 9 patch that can define a center area that is always displayed in correct 1:1 proportion, and border areas at left, right, top and bottom that can be stretched if the image is smaller

Bad 'Patches' in 9-Patch File

核能气质少年 提交于 2019-11-29 05:13:30
问题 I'm attempting to use the Draw9Patch tool from the Android SDK, but immediately upon opening my image with Draw9Patch it shows all of my image area as a 'Bad Patch.' I manually drew in the lines that define the stretchable areas, however I am unsure if this will work properly. Could someone explain why this specific image is not a 'good patch'? Other Stackoverflow answers to this question do not seem to correlate to my problem or I am not understanding them. 回答1: Old, but I had the same

Android seekbar set custom style using nine-patch images

杀马特。学长 韩版系。学妹 提交于 2019-11-29 04:10:01
I am trying to create a custom-styled seekbar. I have two nine-patch images one is a gray stretching bar search_progress.9.png (background color) and the other is a green stretching bar search_progress_bar.9.png (foreground color). I use this xml as my seekbar's progressDrawable: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@android:id/background" android:drawable="@drawable/search_progress"></item> <item android:id="@android:id/progress" android:drawable="@drawable/search_progress_bar"></item> </layer-list> My

Get All Installed Application icons in Android : java.lang.ClassCastException

狂风中的少年 提交于 2019-11-29 03:50:52
There is a java.lang.ClassCastException when I am trying to get a installed applications icon. Here is my code. public Bitmap getAppIcon(String path) { PackageInfo pi = pm.getPackageArchiveInfo(path, 0); pi.applicationInfo.sourceDir = path; pi.applicationInfo.publicSourceDir = path; Drawable icon = pi.applicationInfo.loadIcon(pm); Bitmap APKicon = ((BitmapDrawable) icon).getBitmap(); return APKicon; } where, pm is PackageManager pm = getPackageManager(); and the error shown in the LogCat is Caused by: java.lang.ClassCastException: android.graphics.drawable.NinePatchDrawable cannot be cast to