Android layout - alignment issue with ImageView

后端 未结 2 1392
猫巷女王i
猫巷女王i 2020-12-13 13:01

I\'m trying to put an image at the top left of a LinearLayout, but with the image border and padding taking up the whole of the width of the window.

If

相关标签:
2条回答
  • 2020-12-13 13:10

    Just configure your ImageView on your layout XML file with something like this:

                                <ImageView android:id="@+id/imageViewName" 
                                android:layout_width="90dp" 
                                android:layout_height="90dp" 
                                android:scaleType="fitStart" 
                                android:adjustViewBounds="true" 
                                android:padding="10dp" 
                                android:src="@drawable/ic_contact_picture"
                                android:background="@color/white" />
    
    0 讨论(0)
  • 2020-12-13 13:26

    I was having a similar problem, to which you replied earlier today. Is this on "screen design" viewer provided by the Eclipse plugin side-by-side with the XML editor, or are you encountering the alignment problems when actually running the app? If the former, that appers to be a bug in the plugin, if the latter, try adding:

    android:scaleType="fitStart"
    

    From the documentation I've read, that seems to be the closest to what you need.

    0 讨论(0)
提交回复
热议问题