nine-patch

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

怎甘沉沦 提交于 2019-11-27 17:52:03
问题 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

9-patch image error in Android

瘦欲@ 提交于 2019-11-27 17:35:09
Whenever I try to add a 9-patch image to the \drawable folder in my project, I get the same error: ERROR: 9-patch image C:\...\res\drawable\appwidget.9.png malformed. Frame pixels must be either solid or transparent (not intermediate alphas). Found at pixel #3 along top edge. Failure processing PNG image C:\...\res\drawable\appwidget.9.png The weird thing in this example is that I've got this image from the "android-g1-icon" images found in the SDK resources, so it is supposed to be OK. The same happened with any 9-patch image I've tried so far. What could be wrong? I have encountered with

How to programmatically re-apply a 9-patch image to an ImageView?

杀马特。学长 韩版系。学妹 提交于 2019-11-27 15:43:24
I have an activity that has an ImageView defined inside a HorizontalScrollView. The image source is a 9-patch file that is constrained to stretch only the right edge to fill the screen. I have implemented a simple zoom feature which allows the user to double tap to zoom in and out, by resizing the bitmap and assigning the new bitmap to the view. My current problem is that when doubling tapping to zoom back out, the 9-patch is not applied when I assign the new resized bitmap to the view. In other words, instead of stretching just the right edge as defined in the 9-patch file, it stretched the

how does a 9patch png work in android apps

我的未来我决定 提交于 2019-11-27 15:10:17
In a 9patch png, there are black edges in its four sides, but there is usually difference between the left to right, and the up to down side. Why? How does this difference impact? One of simplest ans is draw the black line according to your requirement using nine patch tools. You can find more information about how nine patch works here The left and top are for scaling, and the right and bottom are for content. So the black lines on left and top will scale to fit, and the content for a button will be "inside" the black lines on the right and bottom. Here http://developer.android.com/guide

Meaning of red color in Android's Nine-patch drawables

大憨熊 提交于 2019-11-27 14:44:07
问题 According to the Android documentation, we know that the left and top black line define the stretchable area, and the bottom and right line define the content area. It's easy to understand, but I found the below image named textfield_activated_holo_dark.9.png from android-17 framework. What is the purpose of the red colors in the lower-left, lower-right and top-right corners? 回答1: I believe this thread has some discussion on the same topic. This has got something to do with setting layout

How to programmatically re-apply a 9-patch image to an ImageView?

左心房为你撑大大i 提交于 2019-11-27 04:07:33
问题 I have an activity that has an ImageView defined inside a HorizontalScrollView. The image source is a 9-patch file that is constrained to stretch only the right edge to fill the screen. I have implemented a simple zoom feature which allows the user to double tap to zoom in and out, by resizing the bitmap and assigning the new bitmap to the view. My current problem is that when doubling tapping to zoom back out, the 9-patch is not applied when I assign the new resized bitmap to the view. In

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

▼魔方 西西 提交于 2019-11-27 03:43:49
问题 I just encountered with a problem that I don't know how to solve. It looks silly but I cannot find a way to fix it. I have a form in android with several EditText and when you submit the form it checks those EditText and if they have wrong data I change the EditText to red border (applying a ninepatch image). myEditText.setBackgroundResource(R.drawable.edittext_red); The problem is, I want to restore android's default style when the user change the EditText, but I don't know how to do it. if

Creating & Using 9-patch images in Android

半城伤御伤魂 提交于 2019-11-27 03:30:11
I recently heard about 9-patch images. I know its 9 tiled and is stretchable. I'd like to know more about it. How can I create a 9-patch image? Is there any tool? Can I create it from AndroidSDK or code? Main Advantages of 9-patch over regular png? (is it stretchable dynamically/ automatically according to screen?) Today I discovered nine patch images. The official documentation (linked to in the other answers) is ok I suppose, but it really lacks in examples. This little tutorial has some great examples at the end that answer the second part of your question, explaining how the scaling works

What should i use for better performance, nine-patch or drawable xml resource?

僤鯓⒐⒋嵵緔 提交于 2019-11-27 02:54:20
问题 What is the best way to set background for some view? For example 2 variants of backround: background with gradient, rounded corners and border background with just one color and rounded corners So which of variants would be better, nine-patch or drawable xml resource? 回答1: My guess is, NinePatch would be slightly faster in most cases. Here's what I found. GradientDrawable (the one used for rects in xml) uses this code to call through to Canvas which in turn uses native call leading to

How to add the bubbles to textview android?

白昼怎懂夜的黑 提交于 2019-11-26 22:44:14
问题 In my application, I want to set bubbles to a text view, in the text view I add the setBackgroundResource() as you can see in the code. With this code i'm getting an image like this: I want a bubble shape image like this: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <solid android:color="#EDF5E4" /> <corners android:bottomLeftRadius="@dimen/corner_radius" android:bottomRightRadius="@dimen/corner_radius"