Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/197.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 位图无法从9块图像中绘制,还需要其高度和宽度_Android_Android Drawable - Fatal编程技术网

Android 位图无法从9块图像中绘制,还需要其高度和宽度

Android 位图无法从9块图像中绘制,还需要其高度和宽度,android,android-drawable,Android,Android Drawable,我已经从Drawablereceive\u btn.9补丁图像创建了位图 BitmapDrawable mimage =(BitmapDrawable) getResources().getDrawable(R.drawable.recieve_btn); 类日志错误 java.lang.ClassCastException: android.graphics.drawable.NinePatchDrawable cannot be cast to android.graphics.drawa

我已经从
Drawable
receive\u btn.9
补丁图像创建了位图

BitmapDrawable mimage =(BitmapDrawable) getResources().getDrawable(R.drawable.recieve_btn);
类日志错误

java.lang.ClassCastException: android.graphics.drawable.NinePatchDrawable cannot be cast to android.graphics.drawable.BitmapDrawable
还想得到高度-宽度一样

  int mheight  = mimage.getBitmap().getHeight();
  int mwidht = mimage.getBitmap().getWidth();

但问题是无法从9面片
图像创建
位图

如果9面片图像仅用于布局或视图的背景,为什么要将其用作位图对象?要获取其高度您是否将其设置为特定视图的背景,然后尝试获取其高度?