drawable

setColorFilter doesn't work on Android < 2.2

筅森魡賤 提交于 2020-01-13 13:37:38
问题 i have a problem with the setColorFilter-Method on a drawable. It works fine on Android 2.2 but not on a version lower than that. My problem is similar to what is described here Drawable.setColorFilter() not working on Android 2.1, but that doesn't work for me... I use this code which works fine on Android 2.2 but not on anything lower than that. ImageView imageView = (ImageView) findViewById( R.id.imageView1 ); Bitmap immutableBitmap = BitmapFactory.decodeResource( getResources(), R.drawable

Difference between android:icon=“@drawable/my_icon” and android:icon=“?my_icon”? [duplicate]

筅森魡賤 提交于 2020-01-13 11:00:07
问题 This question already has answers here : Question mark (?) in XML attributes for Android (2 answers) Closed 5 years ago . I usually set drawable in xml as android:icon="@drawable/my_icon" But in some projects I see the code android:icon="?my_icon" . What's the difference between android:icon="@drawable/my_icon" and android:icon="?my_icon" ? 回答1: Pointing to this document and referencing the answer from there: Applying styles and themes Just like styles, themes are also declared in XML

Android: Where to find the RadioButton Drawable?

萝らか妹 提交于 2020-01-11 08:30:31
问题 Ok, I am trying to create a custom view called CheckedRelativeLayout . It's purpose is the same as a CheckedTextView , to be able to use it in a list of items you want selected or in a Spinner . It's all working fine now, I extended RelativeLayout and implemented Checkable interface. However, I am stuck on a quite simple problem: Where can I find the Drawable that CheckedTextView and RadioButton use? I looked at the sourcecode of both, and they seem to use com.android.internal.R . Well...

Android imagebutton change programmatically?

╄→尐↘猪︶ㄣ 提交于 2020-01-10 05:26:32
问题 Hello I have an imagebutton linearButton which has a background drawable set in the XML. I want to conditionally replace the background within the code, but it never happens! Drawable replacer = getResources().getDrawable(R.drawable.replacementGraphic); linearButton.setBackgroundDrawable(replacer); This seems to be ineffective, is there a "reload" function for a imagebuttons that I have to call before they change visually? 回答1: The invalidate() method will force a redraw of any view: Drawable

Getting Image from drawable and adding to PDF using iText

 ̄綄美尐妖づ 提交于 2020-01-10 02:42:05
问题 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 回答1: Of course it'll not work at that way. move

Set the Background Image of a SurfaceView

余生长醉 提交于 2020-01-09 10:12:26
问题 Is there a way to set the background image of a SurfaceView? Does it have to be done in xml or can I do it all in Java - I've got something that looks like this in my constructor: Drawable sky = (getResources().getDrawable(R.drawable.sky)); this.setBackgroundDrawable(sky); But it still doesn't show anything. 回答1: You cannot set a background drawable on a SurfaceView. You'll have to draw the background onto the surface yourself. 回答2: While you can't directly set a background image to a

Set the Background Image of a SurfaceView

和自甴很熟 提交于 2020-01-09 10:12:05
问题 Is there a way to set the background image of a SurfaceView? Does it have to be done in xml or can I do it all in Java - I've got something that looks like this in my constructor: Drawable sky = (getResources().getDrawable(R.drawable.sky)); this.setBackgroundDrawable(sky); But it still doesn't show anything. 回答1: You cannot set a background drawable on a SurfaceView. You'll have to draw the background onto the surface yourself. 回答2: While you can't directly set a background image to a

详解Android系统如何找到最匹配的资源文件的(译)

梦想的初衷 提交于 2020-01-07 12:36:32
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 当你需要一个资源文件时, Android 系统会在运行时根据当前设备的配置信息从你提供的资源中选择一个文件。为了呈现出 Android 系统是如何选择一个资源文件的这个流程,假定下面的每个 drawable 目录包含了相同的图片元素的不同像素版本: drawable/ drawable-en/ drawable-fr-rCA/ drawable-en-port/ drawable-en-notouch-12key/ drawable-port-ldpi/ drawable-port-notouch-12key/ 同时,假定设备的配置信息如下 : Locale = en-GB Screen orientation = port Screen pixel density = hdpi Touchscreen type = notouch Primary text input method = 12key 通过比较设备的配置信息和可用的资源文件, Android 系统从目录 drawable-en-port 中选择了图片资源。 系统选择出最佳匹配资源文件的算法思路如下: 1. 首先排除那些与设备的配置信息相矛盾的资源文件。 drawable-fr-rCA/ 目录被排除掉 , 因为它跟设备的信息 Locale : en

Android TextView

橙三吉。 提交于 2020-01-07 05:14:06
问题 I have an example in android that I am trying to run. There were 2 ways to do it.. // Get a drawable ColorDrawble redDrawable = (ColorDrawable).getResources().getDrawable(R.drawable.red_rectangle); //Set it as a background to a text view textView.setBackground(redDrawable); When I put this in the Eclipse IDE I get an error ColorDrawble cannot be resolved to a type I have the textview in the main XML <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com

Android: Change size of canvas / drawable in custom drawable

℡╲_俬逩灬. 提交于 2020-01-06 20:35:32
问题 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);