I have the following layout:รถ
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="@android:color/black"
android:gravity="center" >
<ImageView
android:id="@+id/main_gradient"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/gradient"
android:contentDescription="@string/imageview_description"
android:scaleType="centerInside" />
</RelativeLayout>
The 'gradient' image is a jpg with 400 x 400 pixels. My Screen size is 1920 x 1200. I set the Gravity
of my RelativeLayout
to be center
and my ImageView
's height and width are defined to be wrap_content
. I tried scaleType="centerInside"
, fitCenter
and so on and centerInParent="true"
but nothing works. The ImageView
always gets stretched to the screen size.
Why?
How can an ImageView
with wrap_content
Layout params take the whole screen when the content is 400 x 400. I dont get it.
0 comments:
Post a Comment