Tag: 可绘制

你如何从Android包中的资源ID获取可绘制的对象?

我需要得到一个可绘制对象来显示图像button。 有没有办法使用下面的代码(或类似的东西)从android.R.drawable。*包中获取对象? 例如,如果drawableId是android.R.drawable.ic_delete mContext.getResources().getDrawable(drawableId)

获取存储在drawable中的图像的URI

我在我的应用程序中添加了几个示例项目,所以当用户第一次查看时,它看起来不是那么空。 包含示例项目的列表应该有一个图像,我要使用的图像已经存储在应用程序的/ res / drawable-folder中。 由于我已经有一个方法,加载从URI的项目图像我想要的URI到/res/drawable/myImage.jpg,但我似乎无法得到正确的。 stream程如下:使用表示图像URI的string创build项目。 将项目列表发送到列表该列表通过将string转换为URL,然后运行url.openStream()来加载后台任务中的图像。 我已经尝试了一些URI的选项没有任何成功。 “android.resource:// …..”表示未知协议“file://”找不到文件 所以现在我有点失去了如何解决这个问题..

我怎样才能写一个可绘制的资源文件?

我需要将一些Drawable资源导出到一个文件。 例如,我有一个函数返回给我一个Drawable对象。 我想写出/sdcard/drawable/newfile.png文件。 我该怎么做?

如何在活动之间传递drawable

我怎样才能传递一个图像,在活动之间绘制types? 我试试这个: private Drawable imagen; Bundle bundle = new Bundle(); bundle.putSerializable("imagen", (Serializable) unaReceta.getImagen()); Intent myIntent = new Intent(v.getContext(), Receta.class); myIntent.putExtras(bundle); startActivityForResult(myIntent, 0); 但它报告我一个执行: java.lang.ClassCastException: android.graphics.drawable.BitmapDrawable

如何在Android中以编程方式设置背景

设置背景: RelativeLayout layout =(RelativeLayout)findViewById(R.id.background); layout.setBackgroundResource(R.drawable.ready); 是做这件事的最好方法吗?

androidanimation没有在onAnimationEnd中完成

虽然animation.hasEnded被设置为true,但是当onAnimationEnd事件被触发时,似乎Androidanimation并没有真正完成。 我希望我的视图在它的ScaleAnimation的末尾可以修改它的背景,但是你可以清楚地看到它在它完成之前改变了几个毫秒。 问题是,它闪烁,因为新的背景出现(=是)缩短了一段时间,直到animation真的完成。 有没有办法让animation的真实结束,或只是防止新的背景在这么短的时间内缩放呢? 谢谢! //编辑:我正在使用一个AnimationListener来获得以下调用: @Override public void onAnimationEnd(Animation animation) { View view = (MyView) ((ExtendedScaleAnimation) animation).getView(); view.clearAnimation(); view.requestLayout(); view.refreshBackground(); // <– this is where the background gets changed }