drawable

mipmap和drawable文件夹的区别

大憨熊 提交于 2019-12-05 21:34:31
现在,通过Android Studio创建Android工程,默认会创建mipmap文件夹,而不是以前的drawable文件夹。那么mipmap和drawable文件夹到底有什么区别呢? 定位不同 mipmap文件夹下的图标会通过Mipmap纹理技术进行优化。关于Mipmap纹理技术的介绍,请参考: Mipmap纹理技术简介 经过查询官方和第三方资料,得出结论: mipmap文件夹下,仅仅建议放启动图标/app launcher icons,也就是应用安装后,会显示在桌面的那个图标。而其他的图片资源等,还是按照以前方式,放在drawable文件夹下。 下面再详细阐述下,得出以上结论的依据: 1. google官方关于mipmap和drawable的定位 drawable/ For bitmap files (PNG, JPEG, or GIF), 9-Patch image files, and XML files that describe Drawable shapes or Drawable objects that contain multiple states (normal, pressed, or focused). See the Drawable resource type. mipmap/ For app launcher icons. The Android

setColorFilter doesn't work on Android < 2.2

落爺英雄遲暮 提交于 2019-12-05 21:07:04
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.mybitmap ); Bitmap mutableBitmap = immutableBitmap.copy( Bitmap.Config.ARGB_8888, true );

Can handle events on irregular shapes on Android?

时间秒杀一切 提交于 2019-12-05 20:39:28
As far as I know for now (which is little), all the Views in Android have square or rectangular shapes. This is fine almost all the time until you want - what I actually want - to create non-square shapes that could handle events. My goal is to have a circle divided in 3 sections of 120° each. Each section of the circle should behave like a button. The problem is that if we look at those 3rds of a circle and place them in a square box that strictly contains them, they are overlapping each other: not practical to know which the user meant to click... I tried with a custom view in which I drew

Change Button Drawable Programmatically [duplicate]

最后都变了- 提交于 2019-12-05 20:09:49
This question already has an answer here: How to programmatically set drawableLeft on Android button? 13 answers I have a button with drawable left: <Button android:id="@+id/post_feeling_btn" android:background="@color/white" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="4dp" android:drawableLeft="@drawable/feeling_btn" android:gravity="left|center_vertical" android:textColor="@color/gray" android:text="Sentimento"/> In my on resume method, I change the button's text programmatically: Button setFeeling; FeelingButton selectedFeeling; @Override public

Diagonal line across view

喜欢而已 提交于 2019-12-05 18:26:54
Based on some condition, I have to diagonally cut the list cell. For this I have made diagonal drawable image using this code: diagonal_line.xml <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:top="0dp" android:bottom="0dp" > <rotate android:fromDegrees="315" android:toDegrees="315" android:pivotX="0%" android:pivotY="0%" > <shape android:shape="line" > <stroke android:width="10dp" android:color="@color/grey" /> </shape> </rotate> </item> </layer-list> In list cell's xml it is used as: <ImageView android:layout

BitmapFactory.decodeResource and drawable* folders

送分小仙女□ 提交于 2019-12-05 15:47:23
问题 I am wondering if decodeResource (Resources res, int id, BitmapFactory.Options opts) takes into account the drawable-ldpi,mdpi,hdpi etc. folders. I checked the source code, and it doesn't look like that, but I may be missing something. (Generally, where are the R.drawable. resolved in Android source? I was unable to find it.) 回答1: Yes it takes it into account. For example if you do : Resources res = getContext().getResources(); int id = R.drawable.image; Bitmap b = BitmapFactory

How do I add an image in the drawable folder to an ImageView in Android Studio 1.2?

…衆ロ難τιáo~ 提交于 2019-12-05 14:29:27
Since Google added the mipmap folder for the launcher icons, I have had issues using the drawables folder. I manually added the hdpi folders in the drawable folder, but when I try and add the src path, the images won't allow me to view and select them. How do I add an image in the drawable folder to an ImageView in Android Studio 1.2? try with this way of code there are three ways to set image on ImageView imageView.setImageResource(R.drawable.play); or <ImageView android:id="@+id/ivProfileBg" android:src="@drawable/image_name" android:layout_width="wrap_content" android:layout_height="wrap

Android Drawable vs Asset in Image loading performance

我是研究僧i 提交于 2019-12-05 14:28:26
I'm android developer from Korea My project has features about loading large amount of huge bitmap (about 2,000 x 1,500px) I had a some experiments to compare time complexity and space complexity between Asset and Drawable By result, Asset is better than drawable in space complexity. When I load huge images using drawable, my app broken down with OutOfMemoryException : the bitmap size exceeds VM budget but when I load huge images using Asset, It works fine! Anybody know reason why this happened? or Anybody know about how Drawable works in Android framework? step-by-step. Please help. Thank you

Crop Drawable to Square

╄→гoц情女王★ 提交于 2019-12-05 13:07:55
I have a drawable that I have resized to the appropriate desired height (25dp), and the width is scaled proportionally. However, I want an image that is square, with a width of 25dp as well. However, I do not want to distort the image, so I am looking to to crop equal portions of the right and left of the drawable to give me the center 25dpx25dp. Is this possible? How? I have been trying for the past two hours and I'm about ready to throw in the towel... Bitmap target= Bitmap.createBitmap(width, height,Config.ARGB_8888); Canvas canvas = new Canvas(target) float hScale = width/(float)source

ItemizedOverlay Rotate marker and crash

醉酒当歌 提交于 2019-12-05 10:36:54
问题 Bit of a strange post as this is something I posted before, thought it was solved but didn't! I have a situation where I need to use a custom Drawable for each marker, the effect I need is to rotate the marker by a set number of degrees and am probably going the wrong way about this completely. As a start I am using the excellent Creative Commons as this does work and only breaks after my additions! https://github.com/commonsguy/cw-advandroid/tree/master/Maps/NooYawkAsync The previous post