Android在imageview中对齐顶部位图

And*_*oid 2 android android-imageview

无论如何,我可以将位图对齐ImageView.我的图片视图有问题.我正在通过Java代码设置它的源代码,并且在调整位图大小后将其置于中心位置ImageView,但我想要的是对齐位图.

声明imageView:

    <RelativeLayout
    android:id="@+id/collection_background"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="@+id/actionbar" > 


     <ImageView  
        android:id="@+id/collection_image_background"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:background="#ffffff"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:contentDescription="@string/stampii"  />

    // countinue ........
Run Code Online (Sandbox Code Playgroud)

这是我如何设置位图:

BitmapFactory.Options o2 = new BitmapFactory.Options();
    o2.inTempStorage = new byte[8*1024];

    ops = BitmapFactory.decodeStream(cis,null,o2);
    ImageView view = (ImageView) findViewById (R.id.collection_image_background);        
    view.setImageBitmap(ops);
Run Code Online (Sandbox Code Playgroud)

任何想法如何做到这一点?

rml*_*rml 20

添加android:scaleType="fitStart"到您的ImageView.对我来说没关系.

  • 它与 ImageView 的左上角对齐,而不是顶部中心。 (2认同)