Search code examples
androidandroid-layoutviewandroid-relativelayout

Distance Between TextView and ImageView


This is the Layout of a Fragment(attach on the main Activity):

<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"
    tools:context="com.carbos.user.nameapp.Class"
    android:orientation="vertical">

    <!-- TODO: Update blank fragment layout -->
    <TextView
        style="@style/title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/title"
        android:layout_alignParentTop="true"/>

    <ImageView
        android:id="@+id/image"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="0dp"
        android:layout_below="@id/title"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/desc"
        android:layout_below="@id/image"/>
</RelativeLayout>

But the distance between TextView and ImageView doesn't 0dp and there isn't @id/desc. This is the output(the image and title is for example) :

enter image description here

This is the image in Drawable: enter image description here

How can i set the distance between TextView and ImageView( and TextView of @id/desc)? I tried with LinearLayout, but it doesn't work


Solution

  • You should try changing the ScaleType of the ImageView to something else. Probably CenterCrop. For more information see: http://developer.android.com/reference/android/widget/ImageView.ScaleType.html