android Matrix.setRotate is scaling my bitmap -
i trying rotate bitmap in remoteviews. when use either of matrix.setrotate methods or either of matrix.postrotate methods bitmap gets scaled wierd. here code using accomplish task.
bitmap bmap = bitmapfactory.decoderesource(context.getresources(), r.drawable.arrow); matrix m = new matrix(); m.setrotate((float) 0, bmap.getwidth()/2, bmap.getheight()/2); bmap = bitmap.createbitmap(bmap,0,0, bmap.getwidth(),bmap.getheight(),m, true); remoteviews remoteview = new remoteviews(context.getpackagename(), r.layout.speedometer); remoteview.setimageviewbitmap(r.id.speedoneedle, bmap); here original layout file xml:
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="136px" android:layout_height="136px" > <imageview android:layout_width="136px" android:layout_height="136px" android:src="@drawable/dial" /> <imageview android:id="@+id/speedoneedle" android:layout_width="9px" android:layout_height="78px" android:layout_marginleft="63px" android:layout_margintop="27px" android:rotation="-138" android:src="@drawable/arrow" /> </relativelayout> if set rotate value 0 or comment out m.setrotate((float) 0, bmap.getwidth()/2, bmap.getheight()/2) bitmap displays correctly.

if set rotation value 138 this: can barely see needle.

here screenshot of value @ 184:

the needle isn't visible @ max value of 276.
what doing wrong? how can fix it?
thanks in advance.
well, first point of view you've got width of speedoneedle imageview set 9px, not seem enough entire range of angles of arrow bitmap... isn't problem? far understand, you're rotating whole arrow bitmap around center, therefore dimensions of rotated bitmap vary... start, i'd try set width , height of speedoneedle imageview same number.
Comments
Post a Comment