drawable

Android: are images of the same size rendered differently if placed in different drawable folders?

情到浓时终转凉″ 提交于 2019-12-13 08:47:23
问题 does an image of the same pixel dimensions in drawable-hdpi render the same or different in drawable-mdpi folder? 回答1: Yes, they will render differently. Each time you provide higher density images, those images will need to have a larger size in pixels to account for the density but appear at the same size in dp. To convert dp to pixels, multiply a value in dp by the device's density multiplier. mdpi is 1.0, hdpi is 1.5, xhdpi is 2.0. Therefore 100dp in hdpi is actually 150px. An app with an

Drawable Folders

心不动则不痛 提交于 2019-12-13 07:48:29
问题 What is the difference between the 3 drawable folders? I know how drawable works but I don't understand why there are 3 folders. Can an image be accessed if it is in only one folder and can it also be accessed if it is in more than one? I know someone probably has a quick and easy answer for me. Thanks! 回答1: You should read Application Resources and Supporting Multiple Screens sections from documentation. In short, different folders are accessed from different kind of devices. In short:

How to get the drawable name from my image in a list view Android

半腔热情 提交于 2019-12-13 06:26:01
问题 Ok so I have a list view with a custom list view adapter, and each list item has an "icon". when I click the list item, I am easily able to get all the text field names such as name address etc. I have their icon in an image view (obviously every icon is in the same id because it is getting reused in the listview). my question is how can i get the r.drawable.resource (ie pic1) when i click the list item . and pass it to my next intent (I know how to use bundle extras). I have been searching

Android: Distorted background for toolbar icons, list items and overflow menu

非 Y 不嫁゛ 提交于 2019-12-13 05:37:34
问题 While developing an android app, i updated android studio and also android sdk. after that, i faced strange behavior. when clicking on any item like actionbar icons, overflow menu and spinners get distorted background like picture below. my sdk versions are: Android support repository 32 Android support library 23.2.1 Android SDK tools 25.1.6 Android SDK Build-tools 23.0.2 Android 6.0 (API 23) SDK platform Rev 3 its same on emulator and usb device, and cleaning and rebuilding the project didn

appropriate container to display images one by one

巧了我就是萌 提交于 2019-12-13 04:05:31
问题 I am new in android development. And I am building a location based app like google map(To some extent,we are reinventing the wheel :( ). Like maps.google.com ,the map data is generated as tiles in server and re-organized in the client. And in the html page,its easy to find the container to hold the tiles. For example,we can create some img element accordingly, and then put these imgs inside a div element. Now in the android,which is the appropriate container to display the images? In fact, I

How to copy the sample images from the drawable folder to the sdcard folder, programmaticaly?

好久不见. 提交于 2019-12-13 03:58:01
问题 I have pictures/images in my drawable folder and I want to copy all of it in my sdcard folder with that same quality and details? If I have for example this. Integer[] mThumbIds = { R.drawable.pic_1, R.drawable.pic_2, R.drawable.pic_3, R.drawable.pic_4, R.drawable.pic_5, R.drawable.pic_6, R.drawable.pic_7 }; And then my app creates an own directory in sdcard, like this: String newFolder = "/myFolder2"; String extStorageDirectory = Environment.getExternalStorageDirectory().toString(); File

Serialize Object that contains a Drawable Android Java

回眸只為那壹抹淺笑 提交于 2019-12-13 02:58:08
问题 I am trying to save an ArrayList<Plant> ( myPlantList ) to a file with this method. public static void savePlants(Context c){ try { FileOutputStream fOS = c.openFileOutput("plantArrList", c.MODE_PRIVATE); ObjectOutputStream oOS = new ObjectOutputStream(fOS); oOS.writeObject(myPlantList); oOS.close(); fOS.close(); } catch (IOException io) { io.printStackTrace(); } } I get an error (that does not crash the application) java.io.NotSerializableException: android.graphics.drawable.BitmapDrawable .

Which screen size / density combinations should I support for bitmap background image?

回眸只為那壹抹淺笑 提交于 2019-12-12 13:15:28
问题 I'm writing an application where I will need a number of full screen bitmap backgrounds. Based on my naive reading of Supporting Multiple Screens in the Android documentation, to cover all my bases I should probably have 16 versions of each bitmap: all pairs of [ small, normal, large, xlarge ] and [ ldpi, mdpi, hdpi, xhdpi ] . This should reduce the work the CPU has to do for scaling the images, but will come at great storage cost. However, this seems wildly inefficient for two reasons: Not

Programmatically Change Gradient Background of Widget

痞子三分冷 提交于 2019-12-12 10:45:29
问题 What I am trying to accomplish: int[] colors = new int[]{colorDark,colorLight} GradientDrawable gd = new GradientDrawable(TOP_BOTTOM, colors); remoteView.setBackgroundDrawable(gd); //method does not exist Obviously this is not possible. How can I accomplish this? (if it's possible) I do not want to have to create multiple shapes in xml files for different colors, because this limits options. I have tried converting my drawable to a bitmap and calling setImageViewBitmap . I converted with this

Create shape for drawable

谁说我不能喝 提交于 2019-12-12 10:08:11
问题 I have ListView , and i have a background for the list items: Is there any way to recreate this background as a shape in drawable XML? The most outer grey is not part of the item background, it is actually the ListView . 回答1: You can try following with the values of your choice. It will make the bottom two corners rounded. rounded_rectangle.xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape> <gradient android:angle=