I'm trying to add a picture via imageView. But I want to full fill my view with the image and also the imageView should fill the width of the screen. the image should begin and end at the screen edge's.
I used every xml attributes but no luck. This is the closest code to what I want.
<RelativeLayout 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="@drawable/bck3"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<Button
android:id="@+id/buttonStore"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignBottom="@+id/imageView1"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:background="@drawable/store" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/logo" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="fill_parent"
android:layout_height="125dp"
android:layout_marginTop="57dp"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/ronaldo" />
It should be this
The padding is expressed in pixels for the left, top, right and bottom parts of the view. Padding can be used to offset the content of the view by a specific number of pixels. For instance, a left padding of 2 will push the view's content by 2 pixels to the right of the left edge.
Note that padding goes completely around the content: there is padding on the top, bottom, right and left sides (which can be independent). Margins are the spaces outside the border, between the border and the other elements next to this view. In the image, the margin is the grey area outside the entire object.
Padding in Android is used to add a blank space between a view and its contents. Margins, on the other hand, are used to add a space between two different views.
Margin specifies an extra space outside that View on which we applied Margin. In simple words, Margin means to push outside. Diagrammatically, the margin is shown below: Syntax: android:layout_margin=”size in dp”
try removing the following code from relative layout properties:
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
Remove the padding on the parent layout, your imageview will then fill the entire width
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With