drawable

Android TextView drawable, change padding between drawable and text?

自作多情 提交于 2019-11-30 16:46:57
I am creating a TextView with a drawable underneath, in a GridLayout . I want to bring the drawable to the middle of the TextView ; I tried with setCompoundDrawablePadding(-75) and it only changes the position of the text. Current code: TextView secondItem = new TextView(this); GridLayout.LayoutParams second = new GridLayout.LayoutParams(row2, col1); second.width = halfOfScreenWidth; second.height = (int) (quarterScreenWidth * 1.5); secondItem.setLayoutParams(second); secondItem.setBackgroundResource(R.color.MenuSecond); secondItem.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, R

How to set color to secondary drawable in progress bar

守給你的承諾、 提交于 2019-11-30 16:33:54
I have this code pb = (ProgressBar) findViewById(R.id.progressBar1); final float[] roundedCorners = new float[] { 5, 5, 5, 5, 5, 5, 5, 5 }; ShapeDrawable pgDrawable = new ShapeDrawable(new RoundRectShape(roundedCorners, null, null)); String MyColor = "#00FF00"; pgDrawable.getPaint().setColor(Color.parseColor(MyColor)); ClipDrawable progress = new ClipDrawable(pgDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL); pb.setProgressDrawable(progress); pb.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal)); The problem in this code is that for the progress drawable

Android: How to stop Android 1.6+ from scaling images

主宰稳场 提交于 2019-11-30 16:33:29
I updated my build to build against Android 1.6, and now my bitmaps are scaled down on high density screens. I do NOT want this behavior. I gave this a shot: http://blog.tomgibara.com/post/190539066/android-unscaled-bitmaps but the images are STILL scaling, that is UNLESS I set them to a specific height & width. If I use wrap_content they are scaled down. I have an image loader using the unscaled bitmap loader to create a drawable like so: Bitmap bm = UnscaledBitmapLoader.loadFromResource(imageBufferInputStream); drawable = new BitmapDrawable(bm); which I later assign to an ImageView like so:

How to set color to secondary drawable in progress bar

十年热恋 提交于 2019-11-30 16:17:23
问题 I have this code pb = (ProgressBar) findViewById(R.id.progressBar1); final float[] roundedCorners = new float[] { 5, 5, 5, 5, 5, 5, 5, 5 }; ShapeDrawable pgDrawable = new ShapeDrawable(new RoundRectShape(roundedCorners, null, null)); String MyColor = "#00FF00"; pgDrawable.getPaint().setColor(Color.parseColor(MyColor)); ClipDrawable progress = new ClipDrawable(pgDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL); pb.setProgressDrawable(progress); pb.setBackgroundDrawable(getResources()

Android: How to stop Android 1.6+ from scaling images

こ雲淡風輕ζ 提交于 2019-11-30 16:17:11
问题 I updated my build to build against Android 1.6, and now my bitmaps are scaled down on high density screens. I do NOT want this behavior. I gave this a shot: http://blog.tomgibara.com/post/190539066/android-unscaled-bitmaps but the images are STILL scaling, that is UNLESS I set them to a specific height & width. If I use wrap_content they are scaled down. I have an image loader using the unscaled bitmap loader to create a drawable like so: Bitmap bm = UnscaledBitmapLoader.loadFromResource

Saving resources path in SQLite

帅比萌擦擦* 提交于 2019-11-30 15:55:30
问题 I need to save the images in my resource folder in an SQLite database. This database is pre-loaded(copied to data/ path) so the there is no populating at runtime. I've tried to save it like this in text fields in SQLite: "R.drawable.picture1". There are about 300 small size pictures(jpg) in my drawable folder. When I run the a query ofcourse the cursor returns the particulair string. Now I need to set this as ImageResource on an ImageView, but whatever I try it doesn't seem to work. I've

Using Smallest Width configuration qualifier

无人久伴 提交于 2019-11-30 15:22:31
Is it valid to use drawable-swdp- like drawable-sw720dp-xhdpi? Below is my scenario: My Acer iconia tab A501 (10") has a resolution of 1280x800 and density mdpi(160dp). It is expected to take the resource from drawable-sw720dp-mdpi. But the resource is being taken from drawable-sw720dp-xhdpi. I have following folders: drawable-sw720dp drawable-sw720dp-mdpi drawable-sw720dp-hdpi drawable-sw720dp-xhdpi is this the way this qualifier is to be used? or Is the density already considered while calculating the smallest width.So should i be having only one folder of the format: drawable-sw720dp I had

drawable == drawable?

爷,独闯天下 提交于 2019-11-30 14:48:07
This is my problem...: In my activity I have an ImageView and a Button . I want the Button to perform an action ONLY when the ImageView displays a certain drawable. And yes, this means that the ImageView is animating between various drawables that is coded such that it does not interrupt with what I want done. ImageView imgview = (ImageView)findViewById(R.id.imgviewsid); Resources res = getResources(); Drawable acertaindrawable = res.getDrawable(R.drawable.thecertaindrawable); Drawable variabledrawable = imgview.getDrawable(); if (variabledrawable == acertaindrawable) { //does something } It

How to add XML drawable in Eclipse

≯℡__Kan透↙ 提交于 2019-11-30 14:20:34
Ok guys I'm little stacked here. According to official documentation Google says that "Once you've defined your Drawable in XML, save the file in the res/drawable/ directory of your project." is the way to add a XML drawable to the project. But when I created the project ADT created 3 different drawable folders for mdpi, hdpi, and ldpi. So when I wanted to create my XML drawable, I right click on my drawable-hdpi folder and select "Add new Android XML file", and there I have to select what kind of XML file I want to create, but there isn't "drawable" to select. If I create new text file and

Android Drawables memory leak

泪湿孤枕 提交于 2019-11-30 14:05:19
I work with several large drawables and I don't know how to manage memory leaks. I tracked the heap size of my application and it doesn't stop to grow (as the allocated memory). It is especially the "byte array (byte[])" type which grows up and never decrease. (in the DDMS Heap view on Eclipse) My application is composed of one activity which uses fragments. Those fragments are displaying several large images. I tried to set drawables callback to null, set drawables to null, clear my volatile cache (which prevent my app from doing too many disk IO) when I pop back a fragment but the heap never