android-drawable

Change Icon Of Navigation Drawer

非 Y 不嫁゛ 提交于 2019-12-17 15:29:58
问题 I am having trouble with changing my navigation drawer icon to a custom one. I've currently had to implement the standard drawer icon which has 3 horizontal lines on top, but now I want to replace this with my custom drawer icon. This is how my mDrawerToggle is at the moment: mDrawerToggle=new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.app_icon, R.string.drawer_open) { // My code }; 回答1: Here is the sample code taken from Creating a Navigation Drawer Activity.class public class

Drawable image on a canvas

喜夏-厌秋 提交于 2019-12-17 06:28:43
问题 How can I get an image to the canvas in order to draw on that image? 回答1: The good way to draw a Drawable on a canvas is not decoding it yourself but leaving it to the system to do so: Drawable d = getResources().getDrawable(R.drawable.foobar, null); d.setBounds(left, top, right, bottom); d.draw(canvas); This will work with all kinds of drawables, not only bitmaps. And it also means that you can re-use that same drawable again if only the size changes. 回答2: You need to load your image as

Android Studio: Drawable Folder: How to put Images for Multiple dpi?

只愿长相守 提交于 2019-12-17 04:45:21
问题 Hi as per android documentation the drawable folder needs to have multiple sub-directories for images of different dpis. However in Android Studio creating any sub directory in the drawable folder causes it to fail to detect any images at all. On the other hand if an image is placed directly in the drawable folder it gets detected and becomes available for use view R.drawable.ImageName. In this case how do we use different dpi images for the same ImageName? 回答1: The standard procedures are:

How to convert a Bitmap to Drawable in android?

我的未来我决定 提交于 2019-12-17 02:52:17
问题 How can I convert a Bitmap image to Drawable ? 回答1: Sounds like you want to use BitmapDrawable From the documentation: A Drawable that wraps a bitmap and can be tiled, stretched, or aligned. You can create a BitmapDrawable from a file path, an input stream, through XML inflation, or from a Bitmap object. 回答2: Try this it converts a Bitmap type image to Drawable Drawable d = new BitmapDrawable(getResources(), bitmap); 回答3: Having seen a large amount of issues with bitmaps incorrectly scaling

Get the ID of a drawable in ImageView

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 01:58:07
问题 I have one ImageView and set a drawable on it. Now I need to get the ID of the drawable on click event of ImageView dynamically. How can I get it? imgtopcolor = (ImageView) findViewById(R.id.topcolor); imgtopcolor.setImageResource(R.drawable.dr); // How do I get this back? Now on touch event of imgtopcolor i want to need drawable id because I am setting different drawable each time and want to compare the drawable with other 回答1: I think if I understand correctly this is what you are doing.

Android Drawable hdpi xhdpi mdpi ldpi concept [duplicate]

孤街浪徒 提交于 2019-12-14 03:34:17
问题 This question already has answers here : Drawable-hdpi, Drawable-mdpi, Drawable-ldpi Android (2 answers) Closed 6 years ago . I am having one query in drawable concept. I have images of fixed sizes and i have put them in drawable folder. I have deleted my other folders such as drawable-hdpi, mdpi, ldpi, xhdpi from eclipse project and have made the APK of my project. My question is that will my application(generated apk) work on all the devices and tablets( i am not concerned about how the UI

How to check from Robotium that my png is present on the screen?

社会主义新天地 提交于 2019-12-14 02:34:35
问题 I create an additional method: public boolean exampleEdTxt1(){ try{ solo.getCurrentActivity().getResources().getDrawable(R.drawable.action_drw); return true; } catch(AssertionError e){ return false; } } But, when test is runing, code assertTrue(exampleEdTxt1()); always returns success and code assertFalse(exampleEdTxt1()); always returns fail. How to check from Robotium that my png is present on the screen? 回答1: try using .isShown() solo.getCurrentActivity().getResources().getDrawable(R

Could my drawable be interfering with my button state?

时光总嘲笑我的痴心妄想 提交于 2019-12-13 18:35:37
问题 Right now, I have a radio group as the parent and toggle buttons as the children. So something like this: Layout.xml <RadioGroup android:id="@+id/toggleGroup" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white" android:useDefaultMargins="true" android:layout_column="0" android:columnCount="11" android:rowCount="1" android:orientation="horizontal" > <ToggleButton android:id="@+id/number_zero" android:layout_width="34sp" android:layout

Android : Using selector to change button background image and color

被刻印的时光 ゝ 提交于 2019-12-13 15:04:45
问题 I have a button I set its background to specific selector . The selector currently changes the button background and changed an image as the background. I also want the background color to be changed (the image is icon with transparent space around). This is the selector : <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <!-- default --> <item android:state_pressed="false" android:state_focused="false" android:drawable="@drawable

Using same drawable image in two different folder to support all tablets.(same image (no change)in two folders)

孤街浪徒 提交于 2019-12-13 08:59:45
问题 I want to keep same images in two folders drawable-large-xhdpi and drawable-xlarge-hdpi. avoiding duplication of images reduces memory How? I am having images of 1920x1080 resolution Any usefull answer i am very thankful to all. (example: if the image is half of screen width , it should be half of the screen in all tablets) 回答1: If you want to keep exactly the same image in drawable-large-xhdpi and drawable-xlarge-hdpi then you apparently do not really understand what these xhdpi and hdpi