drawable

Set RippleDrawable corner radius programmatically

馋奶兔 提交于 2020-01-03 17:04:22
问题 I create a RippleDrawable like below. But I can't change the corner radius of the RippleDrawable. It doesn't have a method like setCornerRadii(float[] f) . public static RippleDrawable getPressedColorRippleDrawable(int normalColor, int pressedColor) { if (Build.VERSION.SDK_INT>=21) { RippleDrawable rippleDrawable = new RippleDrawable(getPressedColorSelector(normalColor, pressedColor), getColorDrawableFromColor(normalColor), null); //rippleDrawable.setRadius((int) Manager.convertDpToPixel(5));

Android ShapeDrawable set Background and Border programmatically

一笑奈何 提交于 2020-01-03 16:57:05
问题 I have a ShapeDrawable : final ShapeDrawable drawable = new ShapeDrawable(shape); drawable.getPaint().setStyle(Paint.Style.FILL); drawable.getPaint().setColor(0xFFffffff); I want to set border(stroke) color and width for this drawable. I try setStyle(Paint.Style.FILL_AND_STROKE) but it set background and border with same color 回答1: Use drawable.getPaint().setStyle(Paint.Style.STROKE); drawable.getPaint().setStrokeWidth(2); // in pixel 来源: https://stackoverflow.com/questions/31103974/android

setColorFilter is not working sometimes on android drawable

╄→гoц情女王★ 提交于 2020-01-02 19:10:11
问题 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

Null point exception in IMageSwitcher.setImageResource()

♀尐吖头ヾ 提交于 2020-01-02 07:57:47
问题 I am doing an animation to show many images in ImageSwitcher but am stuck in setting images to ImageSwitcher . This is the imageswitcher in my xml. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal"

Preventing shapes scaling in a LayeredList without using Bitmap

血红的双手。 提交于 2020-01-02 01:11:32
问题 Trying to use LayerDrawable (defined in XML as layer-list) to layer several shape drawables onto one another; to be used as a background for a layout. The Android guide (for LayerList) says: All drawable items are scaled to fit the size of the containing View, by default. Thus, placing your images in a layer list at different positions might increase the size of the View and some images scale as appropriate. To avoid scaling items in the list, use a <bitmap> element inside the <item> element

Android: Draw custom border around listview?

為{幸葍}努か 提交于 2020-01-01 14:55:35
问题 I've got a ListActivity with a ListView in it. I need to draw a repeating image around the border ("on top of it (I guess after the listview is renderered)) How can I hook in my own drawing code for this? 回答1: You can use a FrameLayout to cause the ListView to overlap with a view that fills the entire screen. In this background view you could tile an image, or write your own custom View with your own drawing method. 回答2: There is no border property in ListView, as far as I know. Instead you

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

半腔热情 提交于 2020-01-01 09:27:15
问题 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

color value drawable resource issue

匆匆过客 提交于 2020-01-01 08:06:41
问题 I have an image that is 1900*1200 in a folder called drawable-sw600dp that id like to have used on a nexus 7. When I try to run the app the main activity the screen is white and I get the following error: java.lang.NumberFormatException: Color value '@drawable-sw600dp/background5' must start with # at com.android.layoutlib.bridge.impl.ResourceHelper.getColor(ResourceHelper.java:71) at com.android.layoutlib.bridge.impl.ResourceHelper.getDrawable(ResourceHelper.java:248) at android.content.res

Offset shape within a ShapeDrawable

时间秒杀一切 提交于 2020-01-01 04:33:05
问题 I'm trying to draw a rounded rectangle with a border around it using a class that extends ShapeDrawable (see here) and everything is working except that the shapedrawable seems to be cutting off some of the border because the shape itself doesn't extend outside those bounds. Is there not some way to offset where the shapedrawable starts drawing so that there is some padding between the bounds of the shape itself and the canvas? I have tried both ShapeDrawable.setBounds to larger than the

What happens if I leave all of my images in the drawable-hdpi folder?

和自甴很熟 提交于 2020-01-01 04:14:07
问题 I have all of my images in the drawable-hdpi folder. And I finished all of my layouts for all screen sizes. But i forgot to put the images in the drawable-mdpi folder and drawable-ldpi folder. If a phone with an mdpi screen density were to download my application would it just use the images in the drawable-hdpi folder? Or would an error occur because there are no images in the mdpi folder? The only images in the mdpi and ldpi folder is the icon. 回答1: The phone is gonna take the images from