drawable

Android Gradle: can't find symbol variable

霸气de小男生 提交于 2019-12-05 09:50:29
I have a error when building with gradle that says, error: cannot find symbol variable [image_name] . I'm using ContextCompat.getDrawable(getActivity(), R.drawable.[image_name]) I have been googling all over until I found this method to get a drawable without using a deprecated method or setting my min sdk to 21. But now, gradle says it can't find a symbol variable. I have my image in the drawable folder. If you need anything, comment please. EDIT: res: drawable (images under here) drawable-hdpi ... My class: import [package_name].R; import android.graphics.drawable.Drawable; import android.os

Difference between android:icon=“@drawable/my_icon” and android:icon=“?my_icon”? [duplicate]

感情迁移 提交于 2019-12-05 09:40:18
This question already has an answer here: Question mark (?) in XML attributes for Android 2 answers I usually set drawable in xml as android:icon="@drawable/my_icon" But in some projects I see the code android:icon="?my_icon" . What's the difference between android:icon="@drawable/my_icon" and android:icon="?my_icon" ? Pointing to this document and referencing the answer from there: Applying styles and themes Just like styles, themes are also declared in XML elements, and are referenced in the same manner. The difference is that you add a theme to an entire application or activity, via the and

Converting a Drawable to a Bitmap to change the color of a Marker in Google Maps Android API v2

隐身守侯 提交于 2019-12-05 08:20:31
I'm converting an old application from v1 to v2, and I'm having a problem with the color of my Marker icons. I have a basic, white icon, and It needs to be colorized. In v1, I did it this way : Drawable d = DrawableUtils.resizeImageToDrawable( MapViewFragment.mapviewActivity, Configuration.Display.getDrawableFix(i), Configuration.MapView.getWaypointIconWidth(), Configuration.MapView.getWaypointIconHeight()); d.setColorFilter(color, Mode.MULTIPLY); overlay = new MyFplnFixListItimizedOverlay(d); Since v2 Markers do not accept Drawables for their icons, I thought about converting the Drawable to

Change drawable start color and end color dynamically in android activity class

淺唱寂寞╮ 提交于 2019-12-05 07:06:24
问题 Hi I am developing one android application in which I drawable resource to set backgroung for button. I want to change start and end color for that drawable programatically i.e. in activity class inside button click listener. My drawable looks like : <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="#be584c" android:endColor="#be584c" android:angle="270" /> <corners android:radius=

Drawables and Layouts for Galaxy Tab and Motorola XOOM

落爺英雄遲暮 提交于 2019-12-05 06:54:33
问题 I'm testing my app at Galaxy Tab and Motorola XOOM emulator skins, and I can't understand, why the drawables are taken from the wrong folders. I have drawable-xhdpi folder, where I store big size pictures. However, Tab takes drawables from drawable-hdpi, and XOOM uses the drawable-mdpi folder. So, how do I manage my resources? Thanks in advance. In addition, it feels like view sizes defined in sp are not ported properly. I have some views which need to be 80sp x 80sp, on phones with mdpi and

Center a bitmap and repeat the edge pixel

╄→гoц情女王★ 提交于 2019-12-05 06:16:01
I am trying to use an image as background in my android app. If the image doesn't fit the screen I want the image to be centered horizontally and topped vertically. The remaining screen area should be filled by repeating the edges. My layout xml looks like this: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/background_image" > <ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" > ... </ScrollView> <

Setting Drawable as text color raise an exception 'Color value must start with #'

雨燕双飞 提交于 2019-12-05 06:13:41
In a layout I use a button which I set its textColor to a drawable as follows : @drawble/text_color_drawable : <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- disabled state --> <item android:state_enabled="false" android:color="@color/disabled_text_color" /> <item android:color="@color/main_text_color"/> </selector> @color/main_text_color : <color name="main_text_color">#9797A3</color> But when I use this drawable called text_color_drawable as textColor : android:textColor="@drawable/text_color_drawable" I get an exception :

Scale drawableLeft in button with text

一笑奈何 提交于 2019-12-05 05:54:58
I have a button with text and a drawable on the left. Is there any way I can make that drawable scale to it's appropriate size (fill button's height) while keeping its aspect ratio? Relevant excerpt from my layout: <Button android:text="@string/add_fav" android:id="@+id/event_fav_button" android:layout_width="match_parent" android:layout_height="40dp" android:drawableLeft="@drawable/star_yellow"/> You can resize an image on basis of the dimension of a Button, use getHeight() and getWidth() methods to get the size of the button and use following function to resize image for Button: Resizing a

How to access drawable from non activity class

让人想犯罪 __ 提交于 2019-12-05 03:44:56
I am in a situation where I have to use the drawable folder of my app form a non activity class. I tried using the parent activity with the following code: ParentActivity pa = new ParentActivity(); Drawable d = pa.getResources()..getDrawable(R.drawable.icon);` But this returns me a NulLPointerException . How can I achieve this? Pass the context object as a parameter to the constructor of the non Activity class. Then use that context object to get the Resources. Example public class MyClass { Context context; public MyClass(Context context) { this.context = context; } public void urMethod() {

Unable to use android:icon=“@mipmap/ic_launcher” in Manifest after play services 7.5.0

核能气质少年 提交于 2019-12-05 03:37:39
I have recently update play services using dependencies compile 'com.google.android.gms:play-services:7.5.0' My app icon launcher is in @mipmap/ic_launcher" but this is showing error in AndroidManifest.xml . Should i again place this icon in drawable or else ? Help me to find out the solution. UPDATE: Here is Messages from Android studio Error:(17, 9) Execution failed for task ':app:processDebugManifest'. > Manifest merger failed : Attribute application@icon value=(@mipmap/ic_launcher) from AndroidManifest.xml:17:9 is also present at com.pnikosis:materialish-progress:1.0:13:9 value=(@drawable