drawable

How to draw a smaller ShapeDrawable inside another shapeDrawable programmatically

扶醉桌前 提交于 2019-11-29 15:20:36
问题 Im trying to draw a smaller circle within another circle. It seems pretty simple but Im having trouble with this and couldnt find an answer. The code im using is: ShapeDrawable biggerCircle= new ShapeDrawable( new OvalShape()); biggerCircle.setIntrinsicHeight( 60 ); biggerCircle.setIntrinsicWidth( 60); biggerCircle.setBounds(new Rect(0, 0, 60, 60)); biggerCircle.getPaint().setColor(Color.BLUE); ShapeDrawable smallerCircle= new ShapeDrawable( new OvalShape()); smallerCircle.setIntrinsicHeight(

Android - getting an image resource into Uri: IllegalArgumentException

人盡茶涼 提交于 2019-11-29 14:24:35
问题 I'm trying to load an image from the resource in my Android app but I keep getting the "IllegalArgumentException: Expected file scheme in URI" error. I put my 'missing_album_art.png' file in drawable-hdpi, drawable-ldpi and drawable-mdpi folders in my project and refreshed Eclipse so that it displays they're there. The line I'm using to create the Uri is: Uri uri = Uri.parse("android.resource://android.aberplayer/R.drawable.missing_album_art"); The 'android.aberplayer' is the main package of

Rotating ImageView in Android < API Level 11

本小妞迷上赌 提交于 2019-11-29 14:11:47
So in API Level 11 Google introduced the ability to rotate an ImageView (Yay, after they introduced the possibility to Animate such a rotation, yay smart thinking, yay!) But how should I go about to rotate an ImageView using e.g. API level 8? I can't use setRotation() as described above. RotationAnimation was present since Api level 1 RotateAnimation animation = new RotateAnimation(from, to, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setInterpolator(new LinearInterpolator()); animation.setDuration(1); animation.setFillAfter(true); imageView.startAnimation

Drawable advantage over bitmap for memory in android

落爺英雄遲暮 提交于 2019-11-29 12:43:12
问题 This question is linked with the answers in the following question: Error removing Bitmaps[Android] Is there any advantage of using Drawable over Bitmap in Android in terms of memory de-allocation ? I was looking at Romain Guy project Shelves and he uses SoftReference for images caches but I'm unable to search where is the code which is de-allocating these Drawables when SoftReference automatically reclaims the memory for Bitmap. As far as I know .recycle() has to be explicitly called on the

Can not pass bitmap between activities in android

白昼怎懂夜的黑 提交于 2019-11-29 11:29:46
I need to change background of the activity dynamically , by selecting an image from an other activity. and passing the selected image back to the calling activity , but when i try to get the image , it is null. here is my code. public class SelectGoalBackground extends OrmLiteBaseActivity<DatabaseHelper> {// implements{ GridView gridview ; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.select_goal_background); final String from = getIntent().getExtras().getString("from"); goalsList = new ArrayList<Goal>(); try { goalsList =

AnimationDrawable not playing

心不动则不痛 提交于 2019-11-29 11:06:27
问题 So I want my animation to start as soon as the activity is created, but for some reason no matter what I try will get it to start. I can get it to start by having a click event but I want it to start all on its own. Here's what I have and how do I get this to work? package tween.learn; import android.app.Activity; import android.graphics.drawable.AnimationDrawable; import android.os.Bundle; import android.widget.ImageView; public class Animate extends Activity { public ImageView image;

Drawable folders for high resolution handhelds

自闭症网瘾萝莉.ら 提交于 2019-11-29 10:57:20
I can't figure out how to produce drawables for the new "high-res" handhelds like the Galaxy Nexus, One X, Galaxy S3 etc that have a resolution of 1280x720 or higher. I always try to make as few layout-versions as possible. Preferably just one but at times a layout-long and notlong is necessary. And make the xml smart enough to handle all devices. But that's only possible if the drawable resources are there to supply all the different resolutions and sizes. All has been nice and smooth until the new big phones arrived and I find that the drawables are to small for them. No xxhdpi-folder yet

It is possible to remove the Shadow of the Icons (items) on a googlemap?

心已入冬 提交于 2019-11-29 10:24:49
I have a Google map with these kind of items on it: drawable3 = this.getResources().getDrawable(R.drawable.trazeicon); but automatically, Android draws a shadow of the image trazeicon on the map, and I don't want to have that shadow. How can I remove it? EDIT: I got the error: Syntax error, insert "}" to complete ClassBody Here is the full code: package com.GPSLoc; import java.util.ArrayList; import android.app.AlertDialog; import android.content.Context; import android.graphics.Canvas; import android.graphics.Rect; import android.graphics.drawable.Drawable; import com.google.android.maps

Apply an Animation on a Drawable in Android

吃可爱长大的小学妹 提交于 2019-11-29 10:02:49
I am adding a glow animation effect to a logo. So far, I have managed to get the glow image behind the logo, using a LayeredDrawable, but I can't figure out how to animate it. I have found that AlphaAnimation would achieve the desired effect, but unfortunately I can only apply it on Views, not Drawables. How can I achieve this effect? Jeremy Edwards Android 3.0 introduced Property Animations . Unfortunately, this is limited to Android 3.0 and up which won't get on phones any time soon. AndreyNik Simple example final ImageView imageView = (ImageView) findViewById(R.id.animatedImage); final

Android ImageButton - determine what resource is currently set

微笑、不失礼 提交于 2019-11-29 09:42:39
Is there a way I can find what resource a particular ImageButton is set to, at any given time? For eg: I have an ImageButton that I set to R.drawable.btn_on onCreate. Later, at some point, the ImageButton gets set to R.drawable.btn_off . I want to be able to check what resource the ImageButton is set to in my code. Thanks Chris Just use setTag() and getTag() to associate and retrieve custom data for your ImageView . You could define your own class as a child of ImageButton , add a private int variable and set it when setImageResource(int) is called. Something like: public class MyImageButton