drawable

How to get Mat with a drawable input in Android using OpenCV

笑着哭i 提交于 2019-11-30 13:57:32
I have some image files in the drawable folder. And now, I want to convert them into opencv Mat object. I've found a function: Mat img = Highgui.imread(inFile); which is reading a file path to get the Mat. However, I can't get path of my images as I can only read them by using their id like R.drawable.img1. How could I achieve what I want? This should do Mat img = Utils.loadResource(context, refrenceimgID, Highgui.CV_LOAD_IMAGE_COLOR); Imgproc.cvtColor(img, gryimg, Imgproc.COLOR_RGB2BGRA); 来源: https://stackoverflow.com/questions/20184215/how-to-get-mat-with-a-drawable-input-in-android-using

android: fit height of DrawableLeft in a textView

空扰寡人 提交于 2019-11-30 12:44:43
问题 I am trying to display a blue line next to a block of text, pretty much like this: Here's my code: <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:drawableLeft="@drawable/blue_line" /> blue_line is a jpg file. a blue rectangle. it displays in its original size regardless of the text in the textview. how can i adjust its height dynamically according to the height of the text? like make it shorter when theres little amount

How to reference a drawable from a library project into a main project's layout in android?

大憨熊 提交于 2019-11-30 11:38:06
I have a android library project and reusable drawable resources in it. Lets say package name is: com.vijay.mylib; Then i have a main project and it uses the above library project. Lets say its package name is: com.vijay.myproject . Consider that I have linked library project with my main project correctly. In my main project i have a layout called main.xml. I want to use some drawable rom library project in main.xml. How can i do it in xml? Refering in normal way like "@drawable/myImage" didn't work for me. The referece chooser windows shows me the drawables only from main project. Not from

How to draw a smaller ShapeDrawable inside another shapeDrawable programmatically

好久不见. 提交于 2019-11-30 09:59:01
Im trying to draw a smaller circle within another circle. It seems pretty simple but Im having trouble with this and couldnt find an answer. The code im using is: ShapeDrawable biggerCircle= new ShapeDrawable( new OvalShape()); biggerCircle.setIntrinsicHeight( 60 ); biggerCircle.setIntrinsicWidth( 60); biggerCircle.setBounds(new Rect(0, 0, 60, 60)); biggerCircle.getPaint().setColor(Color.BLUE); ShapeDrawable smallerCircle= new ShapeDrawable( new OvalShape()); smallerCircle.setIntrinsicHeight( 10 ); smallerCircle.setIntrinsicWidth( 10); smallerCircle.setBounds(new Rect(0, 0, 10, 10));

Defining XML Parent Style of Gradient / Shape / Corners

坚强是说给别人听的谎言 提交于 2019-11-30 09:12:06
How can I define an easily reusable base shape (or gradient, or corners) in XML? I have a dozen or so drawable gradients that will be the same other than the start and end colors. I was hoping to define the identical stuff somewhere else and have an XML file for each different gradient that only defined the start and end colors. Is that possible? This is the base: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient xmlns:android="http://schemas.android.com/apk/res/android" android:type="linear" android

It is possible to remove the Shadow of the Icons (items) on a googlemap?

纵然是瞬间 提交于 2019-11-30 09:02:33
问题 I have a Google map with these kind of items on it: drawable3 = this.getResources().getDrawable(R.drawable.trazeicon); but automatically, Android draws a shadow of the image trazeicon on the map, and I don't want to have that shadow. How can I remove it? EDIT: I got the error: Syntax error, insert "}" to complete ClassBody Here is the full code: package com.GPSLoc; import java.util.ArrayList; import android.app.AlertDialog; import android.content.Context; import android.graphics.Canvas;

Drawable advantage over bitmap for memory in android

扶醉桌前 提交于 2019-11-30 08:53:13
This question is linked with the answers in the following question: Error removing Bitmaps[Android] Is there any advantage of using Drawable over Bitmap in Android in terms of memory de-allocation ? I was looking at Romain Guy project Shelves and he uses SoftReference for images caches but I'm unable to search where is the code which is de-allocating these Drawables when SoftReference automatically reclaims the memory for Bitmap. As far as I know .recycle() has to be explicitly called on the Bitmap for it to be de-allocated. In my understanding, Bitmaps are typically better for performance if

Android different drawable screen resolutions

浪尽此生 提交于 2019-11-30 08:48:12
I'm a bit confused as to what resolutions I should be saving my images in for the different drawable folders. Is there a general formula for it? For example,if I want an image to take up 10% of the height and the full width of the screen, roughly how would I calculate what different resolutions I should save the image in? This is android's guidelines for icons. Obviously not all drawables are icons, but maybe this helps you get started. 36x36 for low-density 48x48 for medium-density 72x72 for high-density 96x96 for extra high-density From here: http://developer.android.com/guide/practices

Android Drawable: Specifying shape width in percent in the XML file?

荒凉一梦 提交于 2019-11-30 07:19:49
问题 I'm trying to create a simple Drawable that I want to set as the background for a view (using setBackgroundDrawable ). I simply want to divide the background of the drawable into 2 equal rectangles (50% - 50%), the first want filled with black, the second with white: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/back_color_1"> <shape android:shape="rectangle"> <solid android:color="#000000" /> </shape> <

How to programmatically set drawableRight on Android Edittext?

可紊 提交于 2019-11-30 05:56:10
问题 I know about set drawableRight in XML. but i required to do it programmatically because it is change as per some condition. 回答1: You can use the function below: editText.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.drawableRight, 0); or (if you want to pass the drawable itself instead of its ID) editText.setCompoundDrawablesWithIntrinsicBounds(null, null, ContextCompat.getDrawable(context,R.drawable.drawableRight), null) The order of params corresponding to the drawable location