drawable

Android - Loading drawables without skipping frames

独自空忆成欢 提交于 2019-12-25 06:47:01
问题 Okay, so I am using a drawable PNG (1200 x 1920, 30kb) as a background in an activity. A snippet of my XML code is shown below. My problem is the application is skipping frames and has lagged responses. Could anybody tell me why this is happening, or a good way to solve my problem? I still would like to be able to use this PNG file as the background. Thanks XML Snippet: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"

Android Studio - drawable folder missing?

余生颓废 提交于 2019-12-25 04:43:12
问题 I am using Android Studio version 1.2.2 and this how my res folder looks: As you can see there are no drawable folders present. My concern: Is the drawable has been deprecated and instead of it I have to place all the images used in the app in mipmap folders. If I need to create the selectors or any shape for a view I need to place it in the "drawable" or the "mipmap". Does anyone has clue about it? 回答1: Is the drawable has been deprecated and instead of it I have to place all the images used

Tile based map scrolling

假如想象 提交于 2019-12-25 04:08:48
问题 This script draws the map and other stuff: public void render(Canvas canvas) { canvas.drawColor(Color.TRANSPARENT); Drawable myImage; int tileWidth = 50; int tileHeight = 50; int mapWidth = 3; int mapHeight = 3; int rowBaseX = 0; int rowBaseY = 0; int[][] board = new int[][] { {0,0,0}, {0,0,0}, {0,0,2} }; for (int row = 0; row < mapHeight; row++) { for (int col = 0; col < mapWidth; col++) { Resources res = this.getContext().getResources(); switch(board[row][col]) { case 0: myImage = res

Android: Layer drawable loses information

余生长醉 提交于 2019-12-25 03:42:38
问题 I am messing around with creating my own dialog class, but I've run into an interesting issue. I use a layer-list drawable for the dialog's close button, but for some reason, the shadow layer disappears after the first time I show the dialog. You can see in the image below: I really have absolutely no idea what could be causing this. I've tried debugging, but I wasn't able to find any leads. Does anyone have any ideas? My code is below. TwoColorDialog.java public class TwoColorDialog extends

Android Bitmap freeing memory - none of this works

被刻印的时光 ゝ 提交于 2019-12-25 03:36:13
问题 I get "bitmap size exceeds VM budget", eventually with my app. So I added all of these things to help alleviate the increasing memory footprint BitmapFactory.Options options = new BitmapFactory.Options(); options.inTempStorage = new byte[32*1024]; options.inDither=false; //Disable Dithering mode options.inPurgeable=true; //Tell to gc that whether it needs free memory, the Bitmap can be cleared options.inInputShareable=true; //Which kind of reference will be used to recover the Bitmap data

Android: how to attach a resource drawable to an email?

眉间皱痕 提交于 2019-12-25 02:14:45
问题 I'm trying to send an image drawable as an email attachment using the following code: Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, "foo@bar.com"); intent.putExtra(Intent.EXTRA_TEXT, "Lorem ipsum..."); intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("android.resource://"+ getPackageName() + R.drawable.ic_launcher)); startActivity(intent); However I am given a message that the file does not exist. What am I missing here? 回答1:

Align XML drawable background to bottom of view

亡梦爱人 提交于 2019-12-25 01:34:53
问题 I am trying to provide a simple solid-color underline to a TextView header. I want this to be reusable and to work with any view in the future, regardless of height. I am trying to favor a background drawable so I can simply apply it to view. I can draw a line without any problem: <shape xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:shape="line" > <stroke android:color="#8a9299" android:width="1dp" /> </shape> This line is, however,

Android Make Spinner look like ImageView

匆匆过客 提交于 2019-12-25 01:32:13
问题 I've seen this post with a solution to make a Spinner look like an EditText. What I want instead is the spinner to look like an ImageView (the selected Image). This way the Spinner is completely stripped of unnecessary padding and the triangle at the bottom-right. (So on the screen it's an Image, but if you click on it, it opens up like a Spinner.) PS: I already have a custom Spinner with Images as items, but I still have some padding issues and the spinner-triangle that I would like to

How to create a circle drawable?

纵然是瞬间 提交于 2019-12-25 01:13:38
问题 How to a create a drawable of a circle, with blue stroke of 5 pixels and a transparent fill. I will be passing this drawable to an ItemizedOverlay . I want to do this with code and I will know the radius of the circle. 回答1: Try something along the lines of: <shape xmlns:android="http://schemas.android.com/apk/res/android" type="OvalShape" > <stroke android:width="5dp" android:color="#99104E8B"/> .... </shape> Just put something like this in an XML file in you drawables directory and load it

Android Studio: underscores in literals are not supported error

和自甴很熟 提交于 2019-12-24 19:18:18
问题 I have a problem with the drawable class in R.java file. I had drawable hdpi, mdpi, xhdpi... folders in main/res, but drawable was missing so i created it by hand. Main.xml is able to find the image declared but this code in R.java gives an error: public static final class drawable { public static final int 10_device_access_accounts=0x7f020000; public static final int 10_device_access_add_alarm=0x7f020001; public static final int 10_device_access_alarms=0x7f020002; public static final int 10