drawable

Programmatically creating icon to use as ItemizedOverlay drawable - Android

好久不见. 提交于 2019-12-06 13:49:17
问题 I am trying to programmatically draw a parking icon to place as the drawable for an itemized overlay on a map. The icon consists of a blue square with a white 'P' in its centre of which I would like to programmatically change the colour of the square to denote different parking types. I've tried creating it via the canvas using drawRect & drawText but I cannot find a simple way of centering the text in the square and I cannot find a way to center the canvas on the coordinates - it keeps

Android drawables - use xhdpi for hdpi

懵懂的女人 提交于 2019-12-06 11:29:38
Last two questions stayed unanswered, I hope "third one's the charm" works :) I want application that is HDPI use those drawables in folder "drawable-xhdpi" and LDPI devices those in "drawable-mdpi". So I don't have to duplicate same images. Is this possible? Yes, Android scales drawables, selecting the drawable that will produce the best result. But not all scaling combinations work that well. Downscaling to MDPI can produce noticeably poor results. XHDPI to HDPI generally produces pretty good results. But given that the overwhelming majority of devices these days are HDPI, it's probably

Android loading drawable into ImageView taking a lot of memory

試著忘記壹切 提交于 2019-12-06 09:55:04
问题 I'm having a problem. I'm loading 9 drawables into 9 imageViews dynamically. ( drawables are different each time) The drawable id is stored in the object class so when I load this drawable I set the ImageRessource to the imageView by using imageView.setImageRessource(myObject.getRessourceId()); Everything is working fine but when the 9 drawables are loaded, I see on the Android Memory Monitor that the allocate memory reaches 80MB and I think this isn't normal... (Is it?) I tried different

Android: Huge difference in memory consumption when using drawable vs drawable-nodpi folders

女生的网名这么多〃 提交于 2019-12-06 08:26:03
问题 I have basic Android application created with Android Studio with single image loaded in ImageView like this: ImageView iv = (ImageView)findViewById(R.id.imageView); iv.setScaleType(ImageView.ScaleType.CENTER_CROP); iv.setImageResource(R.drawable.g01); Image size is 1280x853 pix , nothing huge. When I store the image in drawable folder runtime memory consumed by app is 24.35 MB vs 11.85 MB when image is stored in drawable-nodpi folder. Tested on xhdpi device with resolution of 1280x720 pix .

Programmatically create Parallelogram Drawable in Android

空扰寡人 提交于 2019-12-06 06:18:36
问题 I am trying to recreate the toggle slide that is seen in Ice Cream Sandwich, but unavailable for Android versions below ICS. I am at the point where I am comfortable with my slider, however I am currently using two parallelogram images (one for its off state, one for its on state). I would like to ideally create the drawable at runtime, and simply change the color of it based on the state. This would really help for customization in the end. I am quite new to drawables in general, and would

Highlight a button when it pressed without using two drawable?

非 Y 不嫁゛ 提交于 2019-12-06 05:29:05
问题 before I use two drawable one when the button state is pressed and an another another as default. so I'm fabricating a hole new image just for simple effect ! So now I'm asking... is it possible to applicate (a color filter or any effect) on the button drawable when that button is pressed ? 回答1: If your button is the standard gray background you can apply a filter in the onClick method for the button to change the color... import android.graphics.PorterDuff; button.getBackground()

Avoid Multiple Drawable Sets (hdpi/mdpi/ldpi)

与世无争的帅哥 提交于 2019-12-06 05:19:13
问题 Is there a way to avoid having multiple sets of drawables per resolution? I have close to 50 images (simple icons mostly, not using anything needing 9-patch), seems like a lot of redundant work to resize all 50 in Photoshop, also considering the rework if I have to change some of the icons in the future. I understand the need for adjusting to multiple densities, but is there any way to avoid it lets say just by providing a high quality image and then enforcing the size as DP/DIP? Also I see

Android using Drawables in an Enum

不羁岁月 提交于 2019-12-06 03:55:17
I have a project that I have to design an array of coins and work with it. My GUI looks like this - http://i.imgur.com/eRzN3Sb.png I want to be able to load the appropriate image from the coinArray for each coin. basically i want to be able to say coinView.setBackgroundResource(coinArray[x].image) i assume i need to somehow use a drawable object and i was hoping its possible to include it in my enum class. the enum class looks like public enum Currency { Penny(1), Nickel(5), Dime(10), Quarter(25); private int value; private Currency(int value) { this.value = value; } } Each coin in the array

clickable drawable inside EditText in android

隐身守侯 提交于 2019-12-06 03:21:16
I have an EditText with a drawable inside. I want to make the drawable clickable so that I can have a specific action when user clicks the drawable. How do I do that? My EditText is: <EditText android:id="@+id/phone" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_marginBottom="5dp" android:drawableRight="@drawable/question_mark" android:hint="phone number" android:imeActionId="@+id/phone_num" android:maxLines="1" android:singleLine="true" android:textColor="#000000" /> As Gina suggested above, you can achieve

Android GLSurfaceView with drawable background

谁说我不能喝 提交于 2019-12-06 02:58:35
问题 I have a GLSurfaceView with a drawable as background, however only the background is visible when rendered without surfaceView.setZOrderOnTop(true) I need to avoid using setZOrderOnTop(true) because there are static TextView's being used on top of the GLSurfaceView. Any suggestions for getting this to work? 回答1: GLSurfaceView cannot really have a background. The way a surface view works is by cutting a hole through your Activity's window and showing another surface behind. Setting