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面片图像仅用于布局或视图的背景,为什么要将其用作位图对象?要获取其高度您是否将其设置为特定视图的背景,然后尝试获取其高度?