drawable

Constrain drawableLeft and drawableRight's height to TextView's height

天大地大妈咪最大 提交于 2019-11-29 09:05:12
I have the following TextView : <TextView android:drawableLeft="@drawable/loading" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Updating Rates" /> And the result is this: How do I make the loading circle drawable constrain proportionally so its height matches the height of the text? Also, if possible, I would like to add some spacing between the text and the image. To make the loading smaller just make the images smaller. Or use RelativeLayout and put the loading in an ImageView and scale it. Or you can add padding between the drawables and the text

Map Marker icon animation (Google Maps API V2 for Android)

混江龙づ霸主 提交于 2019-11-29 08:49:02
On a custom event, I need my Marker to update its drawable 6 times (basically, I want the Marker to grow and shrink 3 times with a delay of 0.5 s between each growth and each shrink) so it notifies the user of said event. Is there any way to achieve this without actually having to remove the Marker and adding it again with a different Drawable ? KlasE I'm afraid there is no way to do it today without actually removing the marker and adding it again with another drawable. I have just done so myself in an attempt to create a progress bar. It works, but it is an awkward way of doing it. Click

How to check if ImageView contains Bitmap or not?

倖福魔咒の 提交于 2019-11-29 08:00:00
I am implementing if a ImageView has bitmap then it should save the image from imageview to internal memory ,otherwise set another bitmap in internal memory of application. here is code:_ croppedImage = cropImageView.getCroppedImage(); croppedImageView = (ImageView) findViewById(R.id.croppedImageView); croppedImageView.setImageBitmap(croppedImage);@Override public void onClick(View v) { // TODO Auto-generated method stub switch (v.getId()) { case R.id.btn_save: counter++; if(croppedImageView.getDrawable() != null) { System.out.println("nullllllllllllll"); try { Bitmap photo = ((BitmapDrawable

Getting Image from drawable and adding to PDF using iText

不想你离开。 提交于 2019-11-29 06:33:44
I want to add image to android PDF using iText. I want to achieve this without saving image to SDCard first. I put my image into res/drawable folder but proving the image path doesn’t work and it throws FileNotFound Exception. My path is like this: String path = “res/drawable/myImage.png” Image image = Image.getInstance(path); document.add(image); Now please suggest me a solution how I will add correct file path to getInstance(…) method. Thanks Festus Tamakloe Of course it'll not work at that way. move your image to assets folder to access it with getassets() method // load image try { // get

How can I set the drawableRight resource via code?

梦想与她 提交于 2019-11-29 06:09:33
I am trying to set an image on the right side of my button after the button has been clicked. I want to do this via code. I have seen how to change the background resource via code but I am not able to find any examples showing how to change the sides via code. Is it possible? You need to use the public void setCompoundDrawables (Drawable left, Drawable top, Drawable right, Drawable bottom) method with null for any that are not needed. luciano.bustos Usually you can change using this Drawable draw = getResources().getDrawable(R.drawable.facebook); myButton

Repeat drawable in imageview?

爷,独闯天下 提交于 2019-11-29 05:44:09
Is it possible to repeat a drawable in an ImageView? I manage to repeat my drawable as a divider in a ListView, but not as an ImageView. Here is my repeated image definition: <bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/xdividerrepeat" android:tileMode="repeat"/> Thanks Markus Matthew Willis You could use a "dummy" view like a LinearLayout to accomplish this. Just create a LinearLayout with the size you need and set its background drawable to be your repeating bitmap. See Android Tile Bitmap . Yes it's possible. You just need to specify the scale

Can I use multiple shapes in one Android drawable?

99封情书 提交于 2019-11-29 05:35:47
What I'm trying to do is define a common background for use in a LinearLayout which frequents my application on many of its Activitys. This particular layout is a header that shows on the top of each activity. What I'm trying to do is create a drawable that fills the linearlayout with a gradient and has a horizontal line below the gradient. Does anyone know if this is possible or do I have to do this sort of thing only with nested layouts. My attemptat the drawable xml is <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape xmlns:android="http://schemas.android

Deep copy of a Drawable

可紊 提交于 2019-11-29 05:35:07
I have an ImageView. In its onClick I get its Drawable: Drawable dr = ((ImageView) v).getDrawable(); And set it to a dialog's ImageView: zoomedImage.setImageDrawable(dr); But when I close the dialog or the activity is resumed. The image at the original position gets stretched and is shown larger than its size, leading to only a portion of the image is visible in the ImageView. Is this a case of deep copy or there is another problem? If it is, how can do I deep copy the original Drawable so that I could set the copy to zoomed image? Thanks in advance. Finally I succeed! I had similar problem,

Loading drawable from sd card

核能气质少年 提交于 2019-11-29 04:40:24
I'm trying to load a png image as a drawable from my device sd card. I use the following function but it doesn't work: public Drawable getDrawable() { return new BitmapDrawable(imagePath); } The image path is: mnt/sdcard/MyFolder/image.png The app crashes when I try calling that method, how should I load my png image located in my sdcard and cast it into a Drawable object? There is actually a BitmapDrawable constructor straight from file path. The method you are using is depricated. Try: Drawable myDrawable = new BitmapDrawable(getResources(), pathName); If this doesnt work, Try getting a

AnimationDrawable don't work in Android 2.2

血红的双手。 提交于 2019-11-29 04:37:28
I using AnimationDrawable like this: ImageView rocketImage = (ImageView) layout.findViewById(R.id.animation); rocketImage.setBackgroundResource(R.drawable.progress_blue_animation); rocketAnimation = (AnimationDrawable) rocketImage.getBackground(); rocketAnimation.start(); This code work in Android 3.0/4.0/4.1/4.0, but don't work in Android 2.2. How to solve this problem? lhlmgr As far as i know, thats a Bug in 2.1, 2.2 A possible workaround could be: ImageView rocketImage = (ImageView) layout.findViewById(R.id.animation); rocketImage.setBackgroundResource(R.drawable.progress_blue_animation);