drawable

NinePatchDrawable does not get padding from chunk

谁都会走 提交于 2019-12-03 12:37:17
问题 I need help with NinePatchDrawable: My app can download themes from the network. Almost all things work fine, except 9-Patch PNGs. final Bitmap bubble = getFromTheme("bubble"); if (bubble == null) return null; final byte[] chunk = bubble.getNinePatchChunk(); if (!NinePatch.isNinePatchChunk(chunk)) return null; NinePatchDrawable d = new NinePatchDrawable(getResources(), bubble, chunk, new Rect(), null); v.setBackgroundDrawable(d); d = null; System.gc(); getFromTheme() loads the Bitmap from the

Draw text inside a circle

走远了吗. 提交于 2019-12-03 12:34:15
问题 I'm working on an Android application and I want to draw a circle with text inside. I want the fill to be white with a black boarder and black text. Right now I have a ShapeDrawable : mDrawable = new ShapeDrawable(new OvalShape()); mDrawable.getPaint().setColor(0xFFFFFF); This however makes the whole circle white (and with a white background you can't see it) and after a while searching as to how you can add text to the shape I can't seem to find an answer that works. I should also note that

Offset shape within a ShapeDrawable

瘦欲@ 提交于 2019-12-03 12:10:53
I'm trying to draw a rounded rectangle with a border around it using a class that extends ShapeDrawable (see here ) and everything is working except that the shapedrawable seems to be cutting off some of the border because the shape itself doesn't extend outside those bounds. Is there not some way to offset where the shapedrawable starts drawing so that there is some padding between the bounds of the shape itself and the canvas? I have tried both ShapeDrawable.setBounds to larger than the intrinsic size of the shape and ShapeDrawable.setPadding but don't seem to be getting anywhere. Should I

Android background image size for XXHDPI

戏子无情 提交于 2019-12-03 09:14:38
问题 I need to set the background picture for my app, the only problem is that i dont know what size the image has to be for XXHDPI devices. I read here for MDPI, HDPI and XHDPI devices, but nothing for XXHDPI: Android splash screen image sizes to fit all devices So, what size does the background has to be for drawable-xxhdpi folder? 回答1: MDPI is your baseline. Means the base size. LDPI is 0.75*MPDI HDPI is 1.5*MDPI XHDPI is 2*MPDI XXHDPI is 3*MDPI XXXHDPI is 4*MDPI See this image for more

Programmatically change drawableLeft of Button

冷暖自知 提交于 2019-12-03 07:21:38
I'm using a Button <Button android:id="@+id/zoom" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@color/trans" android:drawableLeft="@drawable/left_img" android:fontFamily="arial" android:text="My Name is " android:textSize="50sp" /> and changing its text color with : zoom.setTextColor(Color.parseColor("voilet")); but not able to understand how to change its image?? Try this: int imgResource = R.drawable.left_img; button.setCompoundDrawablesWithIntrinsicBounds(imgResource, 0, 0, 0); Reference The safest way to set the left drawable without changing

With default resources in the drawable folder (MDPI sized) what's the point of the drawable-mdpi folder?

江枫思渺然 提交于 2019-12-03 06:25:19
I've a full set of images at the various different pixel densities, and I need to put bitmap resources into the drawables folder (at MDPI) to use as default resources (to prevent crashing on pixel density devices I've not catered to, e.g. xhdpi), but that means duplicating the resources in the drawable-mdpi into the drawable folder. So as duplication is clearly bad, I'm wondering whether I should just delete the drawable-mdpi folder, and keep my MDPI resources in the (default) drawable folder Or am I missing something? You don't need to duplicate your resources. A good practice is to do the

What kind of connection exists between innerRadiusRatio and thicknessRatio from GradientDrawable class?

懵懂的女人 提交于 2019-12-03 06:25:15
问题 Let's supposed we've got a ring with inner radius R2 and outer radius R1. According documentation: Inner radius of the ring expressed as a ratio of the ring's width.For instance, if innerRadiusRatio=9, then the inner radius equals the ring's width divided by 9 As I understand this means that innerRadiusRatio = 2*R1 / R2 . About thicknessRatio there is that: Thickness of the ring expressed as a ratio of the ring's width. For instance, if thicknessRatio=3, then the thickness equals the ring's

Center CheckBox drawable within itself

大憨熊 提交于 2019-12-03 06:22:58
问题 I have a CheckBox that I want centered within its own boundaries, not pushed to the side. Probably easier demonstrated than explained: Note that it isn't centered. Currently defined as: <CheckBox android:id="@+id/checkbox_star" android:layout_width="wrap_content" android:layout_height="match_parent" android:button="@drawable/btn_favorite" android:layout_gravity="center" android:minWidth="48dp" /> Nevermind the custom button drawable. It behaves the same with a vanilla CheckBox as well (the

Set a drawable as background programmatically

佐手、 提交于 2019-12-03 06:21:53
EDIT: Sorry i realize from your comment my question was not clear enough. I will post a new one. Sorry for this and thanks for your answers I am populating a listview from a Json file. With my listadapter, I can easily assign appropriate json data to each row of my list. That works well for text, for example: TextView tv = (TextView)ll.findViewById(R.id.descView); tv.setText(i.desc); With the above code, every row will be correctly populated by the good json data. However, I don't manage to do the same thing for an image. I have tried to set the right image from my json data using this:

Android: drawable resolutions

爱⌒轻易说出口 提交于 2019-12-03 06:16:41
I've been through this post (and others) as well as through the documentation about supporting different screen resolutions in Android, but I couldn't find a clear answer to a (simple) question: Is it ok to just use "res/drawable" for images in an android app? Background: The only images that are needed in this specific app are the app icon itself and an icon for a notification, there won't be any images in any layout. So in my understanding, if no "hdpi"-, "mdpi"- and "ldpi"-folders are found, Android will use "res/drawable" as the fallback. As the only pitfall with different screen