android-drawable

Android ToggleButton not reliably receiving state_pressed

ε祈祈猫儿з 提交于 2019-12-11 10:44:00
问题 I'm attempting to tint a Drawable using DrawableCompat but for some reason the Drawable is not always respecting state_pressed I have a ColorStateList which looks like: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:color="@color/black" android:state_pressed="true" /> <item android:color="@color/yellow" android:state_checked="true" /> <item android:color="@color/gray" /> </selector> I set this on my Drawable like so

Android Studio Adding Images

泄露秘密 提交于 2019-12-11 10:41:21
问题 I am new to android studio. Can any one tell me what is the best way to add images as in eclipse? We have different folder like mdpi, xdpi .. Can any one tell me what is the best way to add images and size also? I am trying with new->image asset but is this right way? what should be image size .. as in eclipse we are adding directly to res->mdpi,xdpi What size should i take? What is asset type in that tool it giving only 3 option ie icon, action and tab, notification which one to be take? 回答1

Icon image in circle shape is blurry

半腔热情 提交于 2019-12-11 10:17:18
问题 I have created circle shape drawables that contain png icons. As per the Android Material guidelines the diameter of the circle is 40dp and the icon is 24dp. Initially I did not set any values for left, right, top and bottom as I assumed the internal icon item would stay 24dp. However, it resizes. I then tried using width and height properties to force it to 24dp, which appeared to work in the preview in AS but had no effect on the tablet. Finally I set the values of top, bottom, left and

Android: Adding badge to corner of drawable on a button

拈花ヽ惹草 提交于 2019-12-11 09:58:31
问题 What is the best way to add a badge icon (Circle with a number in it) to a button's drawable? The drawable is just an image. I was hoping there would be a way to change what I am using as the buttons drawable, and perhaps set it to another drawable that has my image in the middle with a shape on the top right. I will need to update the text of the shape programatically. Here is my button now: <Button android:id="@+id/SpecialsMenuButton" android:layout_width="wrap_content" android:layout

Get drawable for different screen density at runtime

旧城冷巷雨未停 提交于 2019-12-11 08:57:03
问题 I want to print sizes of all drawables at run-time. So if I am on hdpi device then I can print the size of hdpi drawables but how to get access to, lets say mdpi and xhdpi as well? I can get access to all drawables resource ids with following code: final Class<R.drawable> c = R.drawable.class; final Field[] fields = c.getDeclaredFields(); for (int i = 0, max = fields.length; i < max; i++) { final int resourceId; try { resourceId = fields[i].getInt(drawableResources); } catch (Exception e) {

Which element do I need to modify to add padding between a drawable and its enclosed elements?

自古美人都是妖i 提交于 2019-12-11 08:52:41
问题 Based on what I learned here, I was able to add some "fences" around groupings of related widgets: But, as you can see, the second/lower box is crowding the first radio button text. Which element do I need to modify to add some space? Do I need to add something to the box itself, which lives in the drawable folder and is defined like this: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <stroke android:width=

Android Resouce by ID / Change image onClick / no change of imageView

无人久伴 提交于 2019-12-11 07:04:12
问题 I have a problem with my imageview not changing after picking an image from an array (xml resource), but falling back into the default value. Content of my MeasurementActivity.java public class MeasurementActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_measurement); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); final ImageView imageViewMeasurement =

Save array of drawable to file Android

一个人想着一个人 提交于 2019-12-11 04:33:52
问题 im trying to save an arraylist of drawable to a file. Here is my class. public class SeccionItem implements Serializable{ String name; String text; ArrayList<Drawable> img; SeccionItem() { img = new ArrayList<Drawable>(); } } I have an arraylist of that class and i want to write it to a file using objectoutputstream, but i think that drawable cant be serialized, so can i use another type to store the images? like bitmap?. or is there any other way to store that arraylist? overwriting

Using a font and string as a Drawable

非 Y 不嫁゛ 提交于 2019-12-11 03:14:58
问题 In the spirit of simple vector images on Android that always look sharp, I was wondering if I can't use custom font paired with a string (or a character) as a Drawable . For instance, if I wanted to use a Webdings character as the drawable on a Button , how would I do this? I want the best font size to be selected (using dip or sp ) so that I get no distortion on the image. Do you have any ideas how I can accomplish this goal? Thanks! 回答1: You can check out my library IconicTextView It allows

Android: animate circular progress drawable

谁都会走 提交于 2019-12-11 02:56:56
问题 I need a drawable that looks like the rotating progress circle. That drawable I want to use for instance in an ImageView inside a GridView etc. So, according to other posts I took the progress_medium_holo.xml from the folder \sdk\platforms\android-xx\data\res\drawable which looks like this. And I also copied the PNG files which are used by this drawable. <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <rotate android:drawable="@drawable/spinner_48_outer_holo"