Android: Center an image

前端 未结 13 1081
Happy的楠姐
Happy的楠姐 2020-12-07 17:38

I\'ve got a linear layout and an image...





        
13条回答
  •  北海茫月
    2020-12-07 18:07

    Another method. (in Relative tested, but I think in Linear would be also works)

        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:adjustViewBounds="true"
        android:gravity="center"
    

    If you use Eclipse you can choose graphical layout when *.xml file is active. On the top, you will find the Structure and option Adjust View Bounds. It will cut short all dimensions of pseudo-frame (blue rectangle) to size of your drawable file.

    See also the scaleType option with make funny your image. Try it in Eclipse ;)

提交回复
热议问题