drawable

Android : How can i get a image that is in drawable its size in KB, name and extension

北慕城南 提交于 2019-12-12 09:11:26
问题 I have a pic in res/drawable-hpdi/pic.jpg, then i have a alert box that should display the image height width size name and extension, i just cant figure out how to get it act like a file and get its size etc. Bitmap bMap = BitmapFactory.decodeResource(getResources(), R.drawable.pic); File file=new File("res/drawable-hdpi/pic.jpg"); long length = file.length(); if (!file.exists()) { length = -1; } imgInfo = "Height: " + bMap.getWidth() + "\n" + "Width: " + bMap.getHeight() + "\n" +"Size: " +

android how to avoid this out of memory error

柔情痞子 提交于 2019-12-12 09:06:39
问题 I have a lot of images say 500ish spread across 20 or so fragments, the images are all very small and it all loads fine, however i give the user a choice off 3 different kinds of images, and right now if the user changes images i get an OOM error, so i think its the way im handling the images i think i need to recycle the old ones first but im not confident on how to do that can anyone help? here is how i populate my adapter ive just added two items to simplify things private void

Android load drawable programmatically and resize it

浪尽此生 提交于 2019-12-12 08:45:42
问题 How can I load drawable from InputStream (assets, file system) and resize it dynamically based on the screen resolution hdpi, mdpi or ldpi? The original image is in hdpi, I only need resizing for mdpi and ldpi. How does Android do dynamic resizing of the drawables in /res? 回答1: This is nice and easy (the other answers weren't working for me), found here: ImageView iv = (ImageView) findViewById(R.id.imageView); Bitmap bMap = BitmapFactory.decodeResource(getResources(), R.drawable.picture);

Is possible use drawable-mdpi-fr, drawable-hdpi-fr, drawable-ldpi-fr, for localization with different resolutions

与世无争的帅哥 提交于 2019-12-12 07:34:16
问题 I want to use different images for different localisations. However, I have images for all resolutions and for all languages. Is there any way to do this? 回答1: yes, it is possible by. drawable-de-rDE-ldpi,drawable-de-rDE-mdpi . check it. 回答2: Is possible use drawable-mdpi-fr, drawable-hdpi-fr, drawable-ldpi-fr, for localization with different resolutions Yes. Obviously, this gets tedious for too many translations, and if there are too many affected images your APK size may grow substantially.

Creating a sized image out of a string in Java

旧时模样 提交于 2019-12-12 05:31:33
问题 I am making a 2d engine using Java based on entities. The physics and sprites are done, but I still need to be able to draw text with the BaseText class. For experimental purposes I am using the following code in the Renderer class (that handles drawing all the sprites and such): BufferGraphics.drawString(((BaseText) Entity).getText(), (int) -(Origin.getX() * PositionTransform), (int) -Origin.getY()); I would like to, however, be able to either move this code into the setText(final String

Accesing to a drawable through its name in Android

送分小仙女□ 提交于 2019-12-12 03:44:31
问题 I'm developing an app thant handles a SQLite database. I just get some information from it and show it in a list of CardViews. Each CardView basically displays the name, the age and a picture of a person. Everything is working fine, but now that I have implemented the database, I have some doubts about it. I just need to access to the drawables through the name of the files . So far I've been working manually with the R.drawable id, so I could check if it was working. Just like this: Person

Android displays black rectangles instead of drawable images after opening openGL context

那年仲夏 提交于 2019-12-12 03:33:30
问题 I am developing a simple Android app that has a few Activities , say: A , B , C , and D. * Activity A * is a splash screen. Calls finish() when same data finishes loading. Activity B displays some information and a few buttons Activity C starts a webview with the content accordingly to the button pressed in B Activity D opens an openGL context. From Activity A I go to Activity B., from B to C and from C to D. Problem I face: some drawables and a progressBar display black rectangles after

Android Progress Bar slow rotation on pre HoneyComb devices

Deadly 提交于 2019-12-12 02:57:08
问题 I've been trying to achieve an smooth rotation of a drawer in pre honeycomb devices, but it was impossible for me: In my layout.xml <ProgressBar style="@style/ProgressBarLarge" android:layout_centerInParent="true" /> in styles.xml <!-- ProgressBar style --> <style name="ProgressBarLarge" parent="@android:style/Widget.ProgressBar.Large"> <item name="android:layout_width">@dimen/large_size</item> <item name="android:layout_height">@dimen/large_size</item> <item name="android

Location of Holo focused Button drawable

天涯浪子 提交于 2019-12-12 02:35:02
问题 Does anyone know what is the location of Holo theme focused button drawable? I would like to set it to my View on some event, but I can't find it. 回答1: 1.first locate following location in your android sdk platforms folder - yourandroidsdkrootfolderpath\platforms\android-11\data\res\drawable (ex:D:\android\platforms\android-11\data\res\drawable) 2.find the xml file on folder named as btn_default_holo_dark.xml and it's contain like below code: <selector xmlns:android="http://schemas.android

How to get the private drawable to use in activity in android?

ぃ、小莉子 提交于 2019-12-12 02:14:31
问题 I want to use private drawable from android. for that i have downloade androi-8.jar which contains all the .png imgaes i want to use in my activity. i want use "btn_circle_disable_focused " drawable to the buttton but it shows me error regarding private resource. i want to use it in imageview also. 回答1: You should copy desired .png to your project's /drawable folder. you can access it from xml like @*android:drawable/btn_circle_disable_focused but it's not a good idea cause drawable being