drawable

Android Gradle: can't find symbol variable

狂风中的少年 提交于 2019-12-07 06:34:57
问题 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

Unexpected LayerDrawable behavior when drawing layers containing InsetDrawable's

最后都变了- 提交于 2019-12-07 05:57:02
问题 I am trying to build a LayerDrawable in xml where upper layers will occasionally completely obscure lower layers. To make the lower layers smaller, I am using an InsetDrawable to wrap another drawable to make it smaller than the full size of the view. I find unexpectedly, however, that any layers placed on top of the layer containing the inset also has the inset applied to it. I can't find documentation supporting this behavior, and am confused why this would be the case. In the example below

Center a bitmap and repeat the edge pixel

为君一笑 提交于 2019-12-07 04:59:10
问题 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" >

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

爱⌒轻易说出口 提交于 2019-12-07 02:48:21
问题 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)

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

岁酱吖の 提交于 2019-12-07 02:06:07
问题 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

How to access drawable from non activity class

房东的猫 提交于 2019-12-06 23:58:07
问题 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? 回答1: 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

Drawable selector not working in Jelly Bean

久未见 提交于 2019-12-06 18:26:12
问题 I have a drawable selector as a background for each item in a ListView to highlight the selected row. Eveything works fine in Ice Cream Sandwich, but doesn't seem to work in Jelly Bean. Can't find any documentation saying what changes could have caused it to stop working and what I need to do to fix it. By not working, I mean when I click on a row in the ListView the item's background color isn't turning the @color/blue color, but it does in ICS. This is the selector code I'm using (listing

How to programmatically create a round cornered border using ShapeDrawable in android?

依然范特西╮ 提交于 2019-12-06 17:25:43
问题 I need to create a border with rounded corners programatically by extending ShapeDrawable. I need to have a black border with rounded corners with the pixels on the outside being white and the inner pixels being transparent. The code I have at the moment has multiple problems, of which are that it does not create a smooth corner that is the same thickness as the border and that the outer pixels of the border are transparent and not white. Here is a picture of the corners I am currently

Android, Hide stock toggle when using custom background?

守給你的承諾、 提交于 2019-12-06 15:58:28
I've got a custom drawable for my toggle switch // toggle_selector.xlm <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/toggle_on" android:state_checked="true"/> <item android:drawable="@drawable/toggle_off" android:state_checked="false"/> </selector> Which I then apply to the switch <Switch android:id="@+id/geoLocationsToggle" android:background="@drawable/toggle_selector" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="2" android:textOff="" android:textOn=""

setColorFilter is not working sometimes on android drawable

99封情书 提交于 2019-12-06 14:24:30
I am trying to apply color filter on drawable depending on selected primary color in preferences by user. This is the piece of code I am using. getResources().getDrawable(R.drawable.ic_batman_1) .setColorFilter(ColorHelper.getPrimaryColor(), PorterDuff.Mode.OVERLAY); Problem is that, sometimes, this piece of code does not change the color filter of drawable. I have placed this code in my activity (main activity) onCreate and onResume method. So as soon as app launches, I want this color filter to be applied on that drawable but sometimes it is not happening. I also noticed that this problem is