drawable

how to get the source of ImageView in order to change it?

最后都变了- 提交于 2019-12-29 04:40:35
问题 I know that changing the ImageView resource is not big deal just using myImageView.setImageResource(mynewImageDrawable) but what I want to do is to check the current ImageSource before changing it. basically, I want to implement my own group radio buttons using imageViews. so every time any imageView is clicked, the oncliked event method will change the Image Resources of my group. and sorry for my poor English. regards, redsea 回答1: There is no getDrawableId function so you'll need to do

How to create a Drawable from byte[] ? (Android)

自古美人都是妖i 提交于 2019-12-29 04:14:27
问题 I have an array of bytes and I need to convert it into a Android Drawable. How can I perform this conversion? Here is what i tried but without success: byte[] b = getByteArray(); ByteArrayInputStream is = new ByteArrayInputStream(b); Drawable drw = Drawable.createFromStream(is, "articleImage"); drw is always null! EDIT: My byte[] was actually corrupted/incomplete, that was the problem. 回答1: If your byte[] b is contains imagedata then you can also try this, Drawable image = new BitmapDrawable

setBackgroundResource() discards my XML layout attributes

笑着哭i 提交于 2019-12-28 08:06:14
问题 I have a view which is used as an item in a ListView . In my custom adapter, I change the background of the view using View.setBackgroundResource() depending on the item's position in the list. (I have separate assets for the first and last items in the list.) This sets the correct background image as expected, but it has the nasty side-effect that all the padding I'd set in the XML definition of the view is completely ignored. (If I set the background drawable in the XML, and don't try to

android RadioButton button drawable gravity

余生长醉 提交于 2019-12-28 03:30:28
问题 I am generating RadioButtons dynamically with RadioButton radioButton=new RadioButton(context); LayoutParams layoutParams=new LayoutParams(radioWidth,radioHeight); layoutParams.gravity=Gravity.CENTER; radioButton.setLayoutParams(layoutParams); radioButton.setGravity(Gravity.CENTER); BitmapDrawable bitmap = ((BitmapDrawable)drawableResource); bitmap.setGravity(Gravity.CENTER); radioButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.itabs_radio)); radioButton.setButtonDrawable

Applying ColorFilter to ImageView with ShapedDrawable

人盡茶涼 提交于 2019-12-27 17:23:59
问题 I have an ImageView with android:src set to a ShapedDrawable , namely a white circle. What I want is to colorize this ImageView in runtime responding to some events. imgView.setColorFilter seems to be solution, but after using this (tried different parameters) the image becomes invisible (I don't see it at the screen). How to solve this? And are there better ways to have color circles? 回答1: Alright, I had a quick play with this and noticed your issue of the circles disappearing. Without you

Android: programmatically created image vs resource image

删除回忆录丶 提交于 2019-12-25 20:01:14
问题 1) Is it possible to create drawable, example static Bitmap.Config conf = Bitmap.Config.ARGB_8888; static Bitmap bmp = Bitmap.createBitmap(100, 100, conf); // something draw // eventually convert to DrawableBitmap and then convert it / asiggn as / put in resource, to use in function with resource id param, like: public void setWidgetLayoutResource (int widgetLayoutResId) or 2) is it possible to dynamically draw to change image in R.drawable.something.bmp? All this for change color of widget

Draw Bitmap When Still Using XML View

岁酱吖の 提交于 2019-12-25 10:16:18
问题 So I am using my main.xml as a view in my program but I still need to be able to add bimaps/drawables to the screen through programming. Is there any way to do that? public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } That is kinda what my onCreate looks like (but with a lot of code for the purpose of the app). Is there anyway to maybe add a View or Canvas ONTOP of my current view? I am new to bitmaps and drawables for android

Draw Bitmap When Still Using XML View

微笑、不失礼 提交于 2019-12-25 10:16:15
问题 So I am using my main.xml as a view in my program but I still need to be able to add bimaps/drawables to the screen through programming. Is there any way to do that? public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } That is kinda what my onCreate looks like (but with a lot of code for the purpose of the app). Is there anyway to maybe add a View or Canvas ONTOP of my current view? I am new to bitmaps and drawables for android

get images from memory card and store in drawable folder

你离开我真会死。 提交于 2019-12-25 08:39:10
问题 I made a application in which many images are shown, all images are pre-stored in drawable folder of resources, but if i want to add new picture then how can i do this, it should read from memory card but only once, after that it automatically load. 回答1: If I understand correctly, you want to upload images yourself to the app instead of letting user use images or..? If it's you, who should upload new images, you can download them to the app with a check if there are new ones. If it's the user

Android : Share drawable resource with other apps

徘徊边缘 提交于 2019-12-25 07:04:29
问题 In my activity I have an ImageView. I want ,when user click on it, a dialog opens (like intent dialogs) that show list of apps which can open image than user can choose a app and show the image with that app. my activity code : @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ImageView iv = (ImageView) findViewById(R.id.imageid); iv.setImageResource(R.drawable.dish); iv.setOnClickListener(new View.OnClickListener