0

I have an issue making two ImageViews beside eachother without any space between them.

Here's the XML code:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<TextView
    android:id="@+id/txtMeGuess"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="0dp"
    android:layout_marginTop="10dp"
    android:text="1111"
    android:textSize="16sp" />

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_toRightOf="@+id/txtMeGuess"
    android:layout_toEndOf="@+id/txtMeGuess"
    android:layout_alignTop="@+id/txtMeGuess"
    android:layout_alignBottom="@+id/txtMeGuess"
    android:paddingLeft="15dp">

    <ImageView
        android:id="@+id/imgEval1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/green_square"
        android:scaleType="fitStart"
        android:layout_weight="1" />
    <ImageView
        android:id="@+id/imgEval2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/orange_square"
        android:scaleType="fitStart"
        android:layout_weight="1"/>
</LinearLayout>

</RelativeLayout>

This layout gives the design as in the screenshot :

Layout screenshot

What i want to achieve, is that those two squares (Green and orange) to be beside eachother.

This is what i want to achive :

To achieve

Thanks in advance.

MysteryDev
  • 17
  • 7

3 Answers3

0

Use this: android:scaleType="fitXY"

and for more information, check this answer

Community
  • 1
  • 1
Context
  • 1,873
  • 1
  • 20
  • 24
0

Setting layout_weight to Imageview does that exactly in your situation. Try to remove weights.

Change layout to this:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<TextView
    android:id="@+id/txtMeGuess"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="0dp"
    android:layout_marginTop="10dp"
    android:text="1111"
    android:textSize="16sp" />

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_toRightOf="@+id/txtMeGuess"
    android:layout_alignTop="@+id/txtMeGuess"
    android:layout_alignBottom="@+id/txtMeGuess"
    android:layout_toEndOf="@+id/txtMeGuess"
    android:paddingLeft="15dp">

    <ImageView
        android:id="@+id/imgEval1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/green_square"
        android:adjustViewBounds="true"
        android:scaleType="fitStart"
       />
    <ImageView
        android:id="@+id/imgEval2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/orange_square"
        android:adjustViewBounds="true"
        android:scaleType="fitStart"
        />
</LinearLayout>

</RelativeLayout>
Oğuzhan Döngül
  • 7,856
  • 4
  • 38
  • 52
0

I removed the layout_weight and added android:adjustViewBounds="true", and the design became what i wanted to to achieve.

MysteryDev
  • 17
  • 7