我绝对是机器人的新手。我有一个从URL获取的位图。我想在屏幕顶部的一个图像视图的中间显示它。我还想在图像周围画一个边框。目前,当我使用以下代码旋转时,它只会转到顶部:
private static void imageWithBorders(ImageView im, View image){
Matrix matrix = new Matrix();
im.setScaleType(ScaleType.MATRIX);   //required
matrix.setRotate((float) -20f);
im.setImageMatrix(matrix);
im.setImageBitmap(bmp);
}当我设置这样的图像不是在中心,也是如何设置边界围绕它?
我期待着这样的事情。

实现这一目标的任何可能方法都是值得赞赏的。请帮帮我!
提前谢谢!
发布于 2015-03-25 09:25:21
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#10171C"
android:gravity="center" >
    <ImageView
        android:id="@+id/sample"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:contentDescription="@null"
        android:rotation="10"
        android:padding="2dp"
        android:background="@drawable/shadow_gray"
        android:src="@drawable/ic_launcher" />
</LinearLayout>在可绘制的shadow_gray.xml中创建xml文件
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >
    <corners
        android:bottomLeftRadius="0dp"
        android:bottomRightRadius="0dp"
        android:radius="2dp"
        android:topRightRadius="0dp" />
    <stroke
        android:width="1dp"
        android:color="@android:color/white" />
</shape>它不会在xml的图形布局中显示旋转。但是当它运行的时候,它就会像这样出现。

发布于 2015-03-25 05:45:00
用这个:
android:rotation="20"// 20 is the angle将此代码交给ImageView
若要边框,请将ImageView放在LinearLayout中
并将此代码提供给ImageView标记中的
android:padding="5dp"如果你想要边框颜色,那就这么做
给LinearLayout背景加上一个颜色
android:background="#ffffff"//#ffffff is the color code发布于 2015-03-25 05:48:28
Matrix mymatrix = new Matrix();
imageView.setScaleType(ScaleType.MATRIX);
mymatrix.postRotate((float) angle, pivX, pivY);
imageView.setImageMatrix(mymatrix);
这将旋转您的图像视图。
设置padding=1px并将背景色设置为线性布局,THen将有1px边框。如果您需要进一步的澄清,请通知我
https://stackoverflow.com/questions/29248230
复制相似问题