drawable

Android: Drawing tiled bitmaps with bottom or some other alignments similar to css background-position

*爱你&永不变心* 提交于 2019-12-02 04:19:31
问题 I want to set a background of a View with a tiled bitmap, but the tiling needs to be anchored to the bottom-left, instead of the top-left corner (the default). For example, if the tiles are the smiley faces below, I want it to be tiled like: Using xml drawables I could achieve either tiling (using tileMode="repeat" ) or bottom positioning (using gravity="bottom" ), but combining both is not possible, even the documentation says so: android:tileMode Keyword. Defines the tile mode. When the

customizing a drawable for a range of APIs Android

社会主义新天地 提交于 2019-12-02 02:16:34
I'd like to customize one drawable e.g. /drawable/image.png only for APis 19 to 21. For later APIs (after 22 incl. I'd like a drawable to be different). Do I need to create directories drawable-v19, drawable-v20, drawable-v21, drawable-v22 (for the others?) ? It's a bit unclear to me how it works... You should only need to create directories for the versions that set a different resource. So your resources directory would look something like: res/ drawable/ --> SDK version below 19 image.png drawable-v19/ --> SDK version between 19 and 21 (including both) image.png drawable-v22/ --> SDK

Why provide multiple drawables for various densities?

谁说胖子不能爱 提交于 2019-12-02 01:06:40
问题 My app supports various screen densities from ldpi to xhdpi. It contains some drawables (images) that need to be displayed properly on all densities. I'm wondering how many various resolutions of the drawables are actually necessary to provide, considering that Android runtime is scaling resources when it cannot find one for the appropriate density. If you provide only mdpi drawables, they will be scaled up on hdpi/xhdpi (blurry) and scaled down on ldpi screen. However, if you provide only

Setting GradientDrawable through RemoteView

不羁岁月 提交于 2019-12-02 00:10:45
问题 Here is what I want to do: I have a widget and I want to set its background depending upon users choice of colors. It has to be a gradient. The backgound is to be set by setting background of the linearLayout. For testing, I did it for a dummy-background as: remoteViews.setInt(R.id.layout, "setBackgroundResource", R.drawable.widget_background); I have seen this question: Call setImageDrawable from RemoteViews but I am not able to understand how to implement. I even can't find setXYZ() as

android triangle drawablw xml

徘徊边缘 提交于 2019-12-01 22:20:27
I want to draw an equilateral triangle.I have checked but it is inverted.I want a triangle that looks like the image below. Triangle: triangle_shape.xml: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <rotate android:fromDegrees="45" android:toDegrees="45" android:pivotX="-40%" android:pivotY="87%" > <shape android:shape="rectangle" > <stroke android:color="#fff" android:width="1dp"/> <solid android:color="#000" /> </shape> </rotate> </item> </layer-list> Currently it looks like this.. Usign Vector drawable you can

Setting GradientDrawable through RemoteView

喜夏-厌秋 提交于 2019-12-01 21:20:51
Here is what I want to do: I have a widget and I want to set its background depending upon users choice of colors. It has to be a gradient. The backgound is to be set by setting background of the linearLayout. For testing, I did it for a dummy-background as: remoteViews.setInt(R.id.layout, "setBackgroundResource", R.drawable.widget_background); I have seen this question: Call setImageDrawable from RemoteViews but I am not able to understand how to implement. I even can't find setXYZ() as mentioned there. Here is what I have tried until now: Making a gradient drawable dynamically. In this

Why provide multiple drawables for various densities?

江枫思渺然 提交于 2019-12-01 20:30:17
My app supports various screen densities from ldpi to xhdpi. It contains some drawables (images) that need to be displayed properly on all densities. I'm wondering how many various resolutions of the drawables are actually necessary to provide, considering that Android runtime is scaling resources when it cannot find one for the appropriate density. If you provide only mdpi drawables, they will be scaled up on hdpi/xhdpi (blurry) and scaled down on ldpi screen. However, if you provide only xhdi resources, then they will be scaled down on all lower density screens. Scaling down doesn't make

Android: access “system”-drawables

若如初见. 提交于 2019-12-01 19:55:32
I'm currently working on an app to display the battery status and I'd like to use Android-drawables instead of own images to reduce the app size. I've found this page which lists available images and the availability for each SDK-version: http://www.fixedd.com/projects/android_drawables_display My question: How can I access the "system"-drawables? If you click on the link and choose the tab "Status", there are some battery-drawables like "stat_sys_battery_0", but I can't access it, Eclipse doesn't offer intellisense for it and won't compile the app if I use one of those drawables. As those

getDrawable() gives null object while trying to get bitmap from imageview

风格不统一 提交于 2019-12-01 18:03:49
问题 I am using glide for imageview and I want to get bitmap from that imageview-- ImageView imageView = (ImageView) findViewById(R.id.dp); Glide.with(this).load("http://graph.facebook.com/1615242245409408/picture?type=large").into(imageView); Bitmap fbbitmap2 = ((BitmapDrawable)imageView.getDrawable()).getBitmap(); But it gives java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.Bitmap android.graphics.drawable.BitmapDrawable.getBitmap()' on a null object reference

Android: Where to find the RadioButton Drawable?

微笑、不失礼 提交于 2019-12-01 17:23:10
Ok, I am trying to create a custom view called CheckedRelativeLayout . It's purpose is the same as a CheckedTextView , to be able to use it in a list of items you want selected or in a Spinner . It's all working fine now, I extended RelativeLayout and implemented Checkable interface. However, I am stuck on a quite simple problem: Where can I find the Drawable that CheckedTextView and RadioButton use? I looked at the sourcecode of both, and they seem to use com.android.internal.R . Well... that's internal stuff. So I can't access it. Any way to get these Drawables or solve the problem somehow?