nine-patch

Add 9-patch image to Android Studio

醉酒当歌 提交于 2019-12-01 06:53:17
I've created a nine-patch image using the Simple Nine-Patch Generator . This creates a directory with a res -folder, containing folders for each pixel-density-version of the image. In Eclipse with ADT one could simply drag & drop these folders in the res -folder of your project. This would seem like a no-brainer, but how do I add these generated nine-patch images to Android Studio? I'm using Android Studio 1.0.1. If your problem is that you cant find were the drawables are you could eaisly select pakages from the top left side in the project structure there you can find the res folder and you

Why do we need 9-patch?

痴心易碎 提交于 2019-12-01 06:03:50
问题 My question is like title says: Why do we need 9-patch images? Are they really so important? Actually, what they really do? I don't get concept of 9-patch images clearly. I know that 9-patch images are scalable. So let's say I have some image button which perfectly fits on my ldpi device. With Draw 9-patch tool (part of android SDK) I can mark scalable areas and this image will nicely fit on hdpi and even xhdpi devices. Edges will be nice and smooth. But is this really good pratice or is just

Add 9-patch image to Android Studio

让人想犯罪 __ 提交于 2019-12-01 04:37:13
问题 I've created a nine-patch image using the Simple Nine-Patch Generator. This creates a directory with a res -folder, containing folders for each pixel-density-version of the image. In Eclipse with ADT one could simply drag & drop these folders in the res -folder of your project. This would seem like a no-brainer, but how do I add these generated nine-patch images to Android Studio? I'm using Android Studio 1.0.1. 回答1: If your problem is that you cant find were the drawables are you could

Bitmap to NinePatch to New Scaled Bitmap

Deadly 提交于 2019-12-01 00:10:44
My problem is this: I need to create a re-scaled bitmap created using a NinePatch. My current system creates a Bitmap from a NinePatch file. This then gets fed into a NinePatch (or NinePatchDrawable). I then need to resize it and output to another Bitmap. I have reviewed this and it helped quite a bit. Here is my current code: try { Bitmap bitmap1 = BitmapFactory.decodeStream(getAssets().open("gfx/head.9.png")); // Using NinePatch? NinePatch patch = new NinePatch(bitmap1, bitmap1.getNinePatchChunk(), null); // Or NinePatchDrawable? NinePatchDrawable patch = new NinePatchDrawable(bitmap1,

Exception in Drawable.createFromResourceStream() — HTC ONLY?

主宰稳场 提交于 2019-11-30 23:37:35
I've released an IME (soft keyboard) app and I am getting crash reports from HTC phones only . Here is the stack trace: java.lang.NullPointerException at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:465) at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697) at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:666) at com.comet.android.keyboard.util.Util.getBitmapDrawable(MyFile.java:416) ... Here is my call to Drawable.createFromResourceStream() drawable = Drawable.createFromResourceStream(context.getResources(),

Android: compiling 9-patch files to be used outside of the drawable folder?

北城以北 提交于 2019-11-30 21:32:13
I have a need to load 9-patch files from outside of the drawable folder. This is so that my application can download new skins from a server, for example. I have discovered that a 9-patch image stored in the drawable folder is compiled when the .apk is made. The exact same file read from the assets folder does not have the 9-patch chunk. Thus the act of making the .apk is compiling the source 9-patch files in the drawable folder, but not in the assets directory. How can I compile a 9-patch file myself, so that I can install it in the assets directory? Is there a (batch) tool to convert the

Exception in Drawable.createFromResourceStream() — HTC ONLY?

扶醉桌前 提交于 2019-11-30 18:37:31
问题 I've released an IME (soft keyboard) app and I am getting crash reports from HTC phones only . Here is the stack trace: java.lang.NullPointerException at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:465) at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697) at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:666) at com.comet.android.keyboard.util.Util.getBitmapDrawable(MyFile.java:416) ... Here is my call to

Problem with 9 patch image as background

主宰稳场 提交于 2019-11-30 15:00:58
问题 I have a list view structure, with Relative layout that uses alternating background images for odd/even elements. I'm trying to set the background drawable dynamically by calculating the position. It worked fine with the normal bitmap. But when I tried to use the ninepatch image it breaks the UI, all the elements get distorted. What am I doing wrong? Could it be how the ninepatch image is created or is there a different way to use a ninepatch image compared to a normal bitmap. My List View

Could anyone help me with creating 9 patch image from a png image?

吃可爱长大的小学妹 提交于 2019-11-30 15:00:24
I am creating a chat application.I want the to convert my png image for chat bubble into a 9patch image.I used this link.... http://android-ui-utils.googlecode.com/hg/asset-studio/dist/nine-patches.html But the problem is that the chat bubble is always maintaining a minimum width even for small messages.For eg,if i type a text like "hello",it is displayed in a bubble of width much more than the message.How to create 9patch image properly ?? Here is my png image Your 9-patch image needs to be smaller than your smallest message. The system will expand 9-patch images, but will never shrink them

Problem with 9 patch image as background

…衆ロ難τιáo~ 提交于 2019-11-30 13:05:55
I have a list view structure, with Relative layout that uses alternating background images for odd/even elements. I'm trying to set the background drawable dynamically by calculating the position. It worked fine with the normal bitmap. But when I tried to use the ninepatch image it breaks the UI, all the elements get distorted. What am I doing wrong? Could it be how the ninepatch image is created or is there a different way to use a ninepatch image compared to a normal bitmap. My List View XML goes like this <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas