android-drawable

“Class Cast Exception” when trying to set image frames to background

偶尔善良 提交于 2019-12-13 06:13:04
问题 I am trying to make my RelativeLayout background image animate-able by trying to set number of image frames. Here is how I set the animation private View fullView; fullView = (View)findViewById(R.id.fullView); Resources res = getResources(); Drawable drawable = res.getDrawable(R.drawable.eng_anim_1); drawable.setAlpha(100); fullView.setBackgroundDrawable(drawable); AnimationDrawable progressAnimation = (AnimationDrawable) fullView.getBackground(); progressAnimation.start(); Here is my 'list

Replacing Bitmap with Drawable in Drag and Drop Example

浪子不回头ぞ 提交于 2019-12-13 04:37:17
问题 I'm attempting to modify a drag and drop gridView example to use a specific drawable instead of the bitmap used in the example. I believe I'll need to edit the line: Bitmap bmp = Bitmap.createBitmap(150, 150, Bitmap.Config.RGB_565); and change it to something such as Bitmap bmp = R.drawable.sqwhite; but I don't think that's exactly what I'm looking for. Any suggestions? Source: public class DraggableGridViewSampleActivity extends Activity { static Random random = new Random(); static String[]

Android drawable for Samsung Galaxy S4 and Nexus 10

吃可爱长大的小学妹 提交于 2019-12-13 04:32:39
问题 I have an image that is the background of one activity in my app. For the Samsung Galaxy S4 this image should be 1920x1080 and placed at the xxhdpi folder. For the Nexus 10 this image should be 2560x1600 and placed at the xhdpi folder. It's nonsense to place an image bigger in the xhpdi folder than an image placed at the xxhdpi folder. And because that I believe that I misunderstood something. Can someone explain what I misunderstood? --edit-- For all the answer questioning if the nexus10 is

Android: Is it possible to repeat an (SVG!) drawable inside an ImageView?

点点圈 提交于 2019-12-13 03:54:47
问题 I know it's possible to XY repeat a bitmap drawable in an ImageView using this technique: Repeat drawable in imageview? but my drawable is an SVG so I can't create my bitmap.XML . Is there any other technique to treat my case? 来源: https://stackoverflow.com/questions/55581786/android-is-it-possible-to-repeat-an-svg-drawable-inside-an-imageview

Programmatically setting LinearLayout divider size

杀马特。学长 韩版系。学妹 提交于 2019-12-13 03:49:48
问题 I have tried multiple solutions to this but none seem to work! I am currently using the following Drawable as a divider (this is the horizontal example but the same approach works for vertical too, switching height for width). LinearLayout linearLayout; // set with findViewById linearLayout.setDividerDrawable(getResources().getDrawable(R.drawable.divider)); linearLayout.setShowDividers(SHOW_DIVIDER_MIDDLE); Where divider looks like this: <?xml version="1.0" encoding="utf-8"?> <shape xmlns

Crash by org.xmlpull.v1.XmlPullParserException from android.graphics.drawable.Drawable.createFromXmlInner

一曲冷凌霜 提交于 2019-12-13 03:45:26
问题 An app has the following crash that appears to happen only with Samsung Galaxy Android 4.4 devices. android.content.res.Resources$NotFoundException: at android.content.res.Resources.loadDrawable (Resources.java:3422) at android.content.res.Resources.getDrawable (Resources.java:1909) at android.support.v4.content.ContextCompat.getDrawable (ContextCompat.java:465) at android.support.v7.widget.AppCompatDrawableManager.getDrawable (AppCompatDrawableManager.java:203) at android.support.v7.widget

Animating Drawable change in a Button

删除回忆录丶 提交于 2019-12-13 00:24:41
问题 I have a Button that has a BitmapDrawable and a row of text in it. Not that it matter but my drawable is "above" my text which would correspond to the third button from the top. The drawable is set using: BitmapDrawable top = new BitmapDrawable(mContext.getResources(), Bitmap.createScaledBitmap(buttonContent.content, mContext.IMAGE_WIDTH, mContext.IMAGE_HEIGHT, false)); button.setCompoundDrawablesWithIntrinsicBounds(null, top.getCurrent(), null, null); The image that I set initially changes

How to set a gradient background to a Material Button?

帅比萌擦擦* 提交于 2019-12-12 14:32:21
问题 I'm currently using this code but the background is not changing.It is still showing accent-color as background. <com.google.android.material.button.MaterialButton android:id="@+id/materialButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello" app:cornerRadius="32dp" android:background="@drawable/gradiant_blue"/> gradiant_blue.xml <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:angle=

Draw custom drawable shape in android

天涯浪子 提交于 2019-12-12 10:13:12
问题 I want to draw a custom shape in xml layout like below : I tried to do some code in XML but i do not understand how to give shadow effect to outline of this shadow. What i did : <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:width="20dp" android:height="20dp" android:gravity="top|left"> <rotate android:fromDegrees="45" android:pivotX="50%" android:pivotY="50%" android:toDegrees="45"> <shape android:shape="rectangle"

Android: How to make a drawable with a multicolor gradient?

冷暖自知 提交于 2019-12-12 10:09:49
问题 I made this: ShapeDrawable.ShaderFactory shaderFactory = new ShapeDrawable.ShaderFactory() { @Override public Shader resize(int width, int height) { LinearGradient linearGradient = new LinearGradient(0, 0, width, height, new int[]{ 0xF44336, 0xFFB74D, 0xFFE082, 0xAED581, 0x4CAF50, 0xAED581, 0xFFE082, 0xFFB74D, 0xF44336}, new float[]{ 0, 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.75f, 0.875f, 1.0f}, Shader.TileMode.REPEAT); return linearGradient; } }; PaintDrawable paint = new PaintDrawable();