drawable

TransitionDrawable doesn't account for padding?

孤街浪徒 提交于 2019-12-10 23:54:43
问题 I tried the accepted solution posted here, but it appears to ignore padding. When the second view (in this case a button) displays, it's much smaller than the original which has padding. Is there a workaround for that? Thanks 回答1: Yes, TransitionDrawable extends from LayerDrawable which ignores the padding. This is the getPadding() method in the base Android code, which gets rid of anything you specified: @Override public boolean getPadding(Rect padding) { // Arbitrarily get the padding from

Android SetTint no longer working

僤鯓⒐⒋嵵緔 提交于 2019-12-10 21:41:12
问题 I have this code from RatingBar android - custom draw runtime It worked before which I used to change the color of a graphic on my rating control: vthf.rating.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { //-- float touchPositionX = event.getX(); float width = vthf.rating.getWidth(); float starsf = (touchPositionX / width); starsf = starsf * param_final__data.score_max; int starsint =

Android Custom Drawable bounds

纵饮孤独 提交于 2019-12-10 20:34:37
问题 I'm write a custom Drawable, a text over a bitmap: @Override public void draw(Canvas canvas) { canvas.drawBitmap(badge, matrix, null); canvas.drawText(count, size / 2, size / 2 + (text_size) / 2 , p); } When I use my drawable in an imageView, it's fine. But if I use this with a textview (compound drawable) it's alignement is wrong. I tried both setCompoundDrawablesWithIntrinsicBounds and setCompoundDrawables Same results, what did I miss ? Thanks. 回答1: I manage to get the right alignment (my

Android Studio 1.4: drawable-v21 ignored when using “File/New/Vector Asset” option

空扰寡人 提交于 2019-12-10 15:47:10
问题 This is my first SO question so please don't eat me alive... Here's my problem: I've imported few icons via Android Studio 1.4's new option - New/Vector Asset . As you know it lets you easily import and use vector drawables and creates pngs for compatibility with APIs <21. It puts the pngs in folders app/build/generated/res/pngs/debug/drawable-<density> (mdpi, ldpi, hdpi etc). It also generates the -v21 versions of all the folders and puts the vector drawable .xmls there. The problem started,

android xml drawable parameters

你。 提交于 2019-12-10 13:05:39
问题 Is it possible to have an xml drawable with parameters? Suppose I have an xml drawable that I want to reuse for the rounded corners, gradients etc, and the only variable is a color or two. Is it possible to specify/pass parameters to an xml drawable? 回答1: Perhaps you can derive your own class from Drawable, have a constructor accepting the parameters you want to make adjustable and in the constructor first call createFromXML passing your xml and then setup those adjustable parameters. I didn

Remove image resource of ImageButton [duplicate]

末鹿安然 提交于 2019-12-10 12:57:46
问题 This question already has answers here : Remove the image from a imageview Android [duplicate] (4 answers) How to clear an ImageView in Android? (16 answers) Closed last year . I have a transparent ImageButton. When clicked, the ImageResource of the button is set to a drawable in my drawable-hdpi folder (basically an image is shown on top of the transparent ImageButton). I'm using the ImageButton.setImageResource() method in order to do that. My question is, how can I remove the image

How come the behavior of drawableStart doesn't match the Android documentation?

时光毁灭记忆、已成空白 提交于 2019-12-10 12:47:38
问题 I have created a very basic layout: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <Button android:id="@+id/button1" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Button" android:drawableStart="@drawable/ic_launcher"

unable to set multiple bitmap in one imageview

蓝咒 提交于 2019-12-10 12:35:19
问题 this is my activity in i am receiving bitmap and making multiple bitmap and show in one image view i m getting multiple image but not set properly in image view please help me ? private Bitmap Final_Murge_Bitmap() { Murge_Bitmap = null; try { Murge_Bitmap = Bitmap.createBitmap(500, 500, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(Murge_Bitmap); c.drawBitmap(Murge_Bitmap, 0, 0, null); Drawable drawable1 = new BitmapDrawable(Bitmap_recieve); Drawable drawable2 = new BitmapDrawable(Bitmap

Set drawable dynamically for AnalogClock widget

a 夏天 提交于 2019-12-10 11:44:35
问题 How to do that? I have AnalogClock on my xml. And I want drawable for the android:dial to change programatically. I tried remoteviews.setImageViewResource(R.id.AnalogClock, R.drawable.w0); or remoteviews.setInt(R.id.AnalogClock, "setDialResource", R.drawable.w0); Both can not accomplish it. Anyone manage to do this? 回答1: Finally make it works. I put transparent image on AnalogClock android:dial Then use FrameLayout to overlay ImageView and AnalogClock. Then use remoteviews.setInt(R.id

Android drawables - use xhdpi for hdpi

醉酒当歌 提交于 2019-12-10 10:34:48
问题 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? 回答1: 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