android-drawable

Can I override some attribute of drawable shape?

二次信任 提交于 2019-12-10 19:08:37
问题 I have two buttons, they are same shape, only color is different b1.xml <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <corners android:radius="10dp" /> <stroke android:width="5px" android:color="#000000" /> <solid android:color="#ff0000"/> </shape> b2.xml <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <corners android:radius

Glide is loading half image

 ̄綄美尐妖づ 提交于 2019-12-10 17:44:48
问题 When I try to load image with I get this result: This is my simple code: Glide.with(this).load(R.drawable.girl_with_coffee_and_phone) .placeholder(R.color.colorPrimary) .into(mBackgroundImage); This is my activity layout: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/image_background" android:layout_width="match_parent"

How to convert LayerDrawable to Bitmap?

爷,独闯天下 提交于 2019-12-10 14:44:46
问题 I'm using the Universal Image Loader for Android (here is the link) I need to to load an Image from a URL and overlay it to another image. The library can not do it by default, so I'm try to change it. The problem is that now I need to convert a LayerDrawable to Bitmap. How can I do that? 回答1: Just draw it on a Canvas which is backed by a Bitmap. int width = drawable.getIntrinsicWidth(); int height = drawable.getIntrinsicHeight(); Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB

Set Color to the drawableTop image inside a TextView in android

流过昼夜 提交于 2019-12-10 14:18:02
问题 I have a textView with drawableTop, but the image is in black color and i would like to change the color to white.Is there a way to do it without creating seperate imageView and TextView. Below is the xml for reference. <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="48dp" android:layout_height="48dp" android:gravity="center_horizontal|bottom" android:drawableTop="@drawable/ic_add_room" android:text="More"/> 回答1

Android - Get Color From ImageView with ColorFIlter Applied to Drawable

帅比萌擦擦* 提交于 2019-12-10 13:52:55
问题 I'm trying to get the color of an ImageView within a GridView that I've applied a color filter too previously. I'm running on a Nexus 4 with 4.2.2 I'm altering the color of the ImageView like this. The actual color of the image is white before I apply a filter. Drawable myIcon = getResources().getDrawable(R.drawable.bufferbuildercolor3); myIcon.setColorFilter(new PorterDuffColorFilter(Color.rgb(Color.red(color),Color.green(color), Color.blue(color)),PorterDuff.Mode.MULTIPLY)); Now this doesn

How can I define the size of the drawables in the style file?

早过忘川 提交于 2019-12-10 13:42:59
问题 I would like to specify just once in res/values/styles.xml the size of two checkboxes and their four shape drawables res/drawable/cb1_checked.xml res/drawable/cb1_unchecked.xml res/drawable/cb2_checked.xml res/drawable/cb2_unchecked.xml . This way the size would appear one time in the style rather than four in the drawables. Neither of the two attempts below work. Can you suggest a solution? (If you see what's wrong with these two attempts, please do mention it.) -----------------------------

How to set image size when using setCompoundDrawablesWithIntrinsicBounds()?

家住魔仙堡 提交于 2019-12-10 13:09:58
问题 I need to set image above text in tabs in Tab Layout. So I set image in my TextView using setCompoundDrawablesWithIntrinsicBounds but I don't know how give size for my image. I tried to give size like this: Drawable dr = ContextCompat.getDrawable(MainActivity.this, R.drawable.mobile_icon); Bitmap bitmap = ((BitmapDrawable) dr).getBitmap(); mobile_drawable = new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(bitmap, 50, 50, true)); TextView tabOne = (TextView) LayoutInflater.from

Add Color “#e3bb87” to StateListDrawable programmatically

爷,独闯天下 提交于 2019-12-10 10:27:23
问题 The reason I need to do this programmatically is that the text color is downloaded and not pre defined in the xml. I read this Replace selector images programmatically I only need to know from StateListDrawable states = new StateListDrawable(); states.addState(new int[] {android.R.attr.state_pressed}, getResources().getDrawable(R.drawable.pressed)); how turn into states.addState(new int[] {android.R.attr.state_pressed},**theMethodImLookingFor**("#e3bb87")); forget about getResources()

Found unexpected optical bounds (red pixel) on top border at x=14

眉间皱痕 提交于 2019-12-10 10:09:22
问题 Recently, I'm updating to Android Studio 3.3 and Gradle 3.3, in this version the gradle.property 'android.enableAapt2=false' has no effect because AAPT2 is now always used. The real problem comes when I delete this line, because can't compile, the next error that throws is: Android resource compilation failed error: found unexpected optical bounds (red pixel) on top border at x=14. In the previous versions we can solve this problem as in this post. Now I can't compile my app cause exists this

Can't get rid of shadow under Android Button

痴心易碎 提交于 2019-12-10 06:18:21
问题 I have a Android Button that I'm placing on my screen, and am defining a custom background drawable that just specifies a green rectangle for now. But, for some reason there appears to be a very thin shadow being drawn under my button (highlighted with the red box): Is there any way to get rid of this while still using a Button? It because really ugly when I change my background drawable to have rounded corners. Thanks! 回答1: @alanv's comment was the correct answer: "On Material you need to