drawable

Android: Change size of canvas / drawable in custom drawable

荒凉一梦 提交于 2020-01-06 20:35:21
问题 I'm trying to implement a custom drawable which should have the shape of a speechbubble. Therefore I use two paths, one draws the rect and the other should draw the triangle for the bubble. My class looks like the following: public class SpeechBubbleView extends Drawable { private Paint mBubblePaint; private Paint mBubblePaint2; private Path mRectPath; private Path mBubblePath; public SpeechBubbleView() { } public void initPaint() { mBubblePaint = new Paint(Paint.ANTI_ALIAS_FLAG);

How would I do this?(Android Whack-A-Mole)

我怕爱的太早我们不能终老 提交于 2020-01-06 05:06:07
问题 I'm making a simple whack-a-mole game as my first mini-project for android. I'm not sure how to go about this. I know the basics of setting everything up and such but I'm not sure how to animate the moles and make it so that when the mole is in the up position it can be tapped and a point will be counted. I know I can do an image button and have a counter go up(counter++) but I need to be able to switch frames from the mole in the hole to the mole in the up position. I've been told to use a

How would I do this?(Android Whack-A-Mole)

…衆ロ難τιáo~ 提交于 2020-01-06 05:06:04
问题 I'm making a simple whack-a-mole game as my first mini-project for android. I'm not sure how to go about this. I know the basics of setting everything up and such but I'm not sure how to animate the moles and make it so that when the mole is in the up position it can be tapped and a point will be counted. I know I can do an image button and have a counter go up(counter++) but I need to be able to switch frames from the mole in the hole to the mole in the up position. I've been told to use a

Saving Image Retrieved from InputStream locally

与世无争的帅哥 提交于 2020-01-05 12:32:34
问题 I used the following code to retrieve an image from a url and display it within an activity. InputStream is = (InputStream) new URL(url[0]).getContent(); Drawable d = Drawable.createFromStream(is, "imagename"); ImageView... Now I want to save this image (Drawable d) locally when a user clicks a button so I can display it again in another activity (along with a few other tasks). I'd like to store it within the app folder itself rather than on the SD card. How would I do this? Thanks! Shannon

Saving Image Retrieved from InputStream locally

雨燕双飞 提交于 2020-01-05 12:31:10
问题 I used the following code to retrieve an image from a url and display it within an activity. InputStream is = (InputStream) new URL(url[0]).getContent(); Drawable d = Drawable.createFromStream(is, "imagename"); ImageView... Now I want to save this image (Drawable d) locally when a user clicks a button so I can display it again in another activity (along with a few other tasks). I'd like to store it within the app folder itself rather than on the SD card. How would I do this? Thanks! Shannon

Bitmap drawable (Map Overlay Item) pixelizes after rotation in android

天大地大妈咪最大 提交于 2020-01-05 05:40:10
问题 I'm trying to rotate an overlay drawable to represent an overlay item in Android. I use this: Bitmap bmpOriginal = BitmapFactory.decodeResource(this.getResources(), R.drawable.map_pin); Bitmap targetBitmap = Bitmap.createBitmap((bmpOriginal.getWidth()), (bmpOriginal.getHeight()), Bitmap.Config.ARGB_8888); Matrix matrix = new Matrix(); matrix.setRotate((float) lock.getDirection(),(float) (bmpOriginal.getWidth()/2), (float)(bmpOriginal.getHeight()/2)); Canvas tempCanvas = new Canvas

Android - Setting both TileMode and Gravity

眉间皱痕 提交于 2020-01-04 02:29:47
问题 I have a ListView in an XML-layout. I want to set a new background to this view by using the following code: BitmapDrawable TileMe = new BitmapDrawable(BitmapFactory.decodeResource(getResources(), R.drawable.bg_skyline)); TileMe.setGravity(Gravity.BOTTOM); // Bottom TileMe.setTileModeX(Shader.TileMode.REPEAT); ListView test = getListView(); test.setBackgroundDrawable(TileMe); The problem is that if I leave both the Gravity and the TileMode lines uncommented, only TileMode will work. If i

Attaching an drawable image to email in android

北城以北 提交于 2020-01-03 21:05:47
问题 I have a list of Drawable images in my application and want to send one of the images through mail. my code looks like Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.setType("image/*"); sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Picture"); sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(lstPhotos.get(newPosition).getPhotoURL())); myActivity.startActivity(Intent.createChooser(sendIntent, "Email:")); But in the above code i have a problem since i cannot get the image URI from

Drawable loses color filter after converting into bitmap

末鹿安然 提交于 2020-01-03 20:06:05
问题 I am trying to add a color filer in a drawable and then convert it in Bitmap. The problem is when convert the drawable into bitmap it loses it's color filter.I used drawable in imageview and its have the color filter but using bitmap in imageview doesn't have any color effect. Why this happen ? Thanks in advance. 回答1: Use a canvas to blit the Drawable back onto a bitmap: Canvas canvas; Drawable drawable = <yourDrawable created from wherever>; Bitmap bmp = <your Bitmap which is the same width

Drawable loses color filter after converting into bitmap

非 Y 不嫁゛ 提交于 2020-01-03 20:04:15
问题 I am trying to add a color filer in a drawable and then convert it in Bitmap. The problem is when convert the drawable into bitmap it loses it's color filter.I used drawable in imageview and its have the color filter but using bitmap in imageview doesn't have any color effect. Why this happen ? Thanks in advance. 回答1: Use a canvas to blit the Drawable back onto a bitmap: Canvas canvas; Drawable drawable = <yourDrawable created from wherever>; Bitmap bmp = <your Bitmap which is the same width