Sneaky And Stuff
Sneaky And Stuff

Reputation: 37

Fitting image in lay-out android project

I have added a transparent picture in my layout. Now that it's transparent, the sizing is kind of different. It has some space above the image, while I want it to be completely on top. It's about the image in the top left of the screen, the bar with the colors. Above that bar, there is some open space. I want that bar to be completely in the top left, leaving no open space between the bar and top ending of the screen.

Unfortunately i have no idea how to do this. I've changed the size of the image, but that won't help. Does anyone of you have an idea?

This is the image I'm talking about :

enter image description here

I appreciate any help, thanks in advance.

EDIT: this is my xml code. the Imageview with drawable/logoversiejuni is the part with the logo:

<LinearLayout 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:orientation="vertical"
    tools:context="com.example.rodekruis.MainActivity"
    android:background="@drawable/atrium">


   <LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.example.rodekruis.MainActivity">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    <ImageView
        android:id="@+id/imageButton1"
        android:layout_width="40dp"
        android:layout_height="50dp"
        android:layout_marginBottom="20dp"
        android:layout_marginRight="40dp"
        android:layout_marginTop="10dp"
        android:layout_gravity="right" 
        android:src="@drawable/informatiebutton" />

    <ImageView
        android:layout_marginBottom="20dp"
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:layout_marginLeft="1dp"
        android:layout_marginTop="1dp"
        android:src="@drawable/logoversiejuni" />

 </FrameLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginBottom="20dp"
        android:layout_marginTop="50dp"
        android:orientation="horizontal">

        <ImageButton

            android:id="@+id/button10"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_alignTop="@+id/button8"
            android:layout_marginRight="5dp"
            android:layout_marginLeft="2dp"
            android:layout_weight="1"
             android:layout_marginTop="0dp"
             android:adjustViewBounds="true"
            android:padding="5dp"
            android:scaleType="fitCenter"
            android:src="@drawable/afspraakbutton"
            android:text="  Afspraak   maken" />


        <ImageButton

            android:id="@+id/button10"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_alignTop="@+id/button8"
            android:layout_marginRight="5dp"
            android:layout_marginLeft="2dp"
            android:layout_weight="1"
             android:layout_marginTop="0dp"
             android:adjustViewBounds="true"
            android:padding="5dp"
            android:scaleType="fitCenter"
            android:src="@drawable/bezoektijdenbutton"
            android:text="  Bezoek  tijden" />

          <ImageButton

            android:id="@+id/button10"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_alignTop="@+id/button8"
            android:layout_marginRight="5dp"
            android:layout_marginLeft="2dp"
            android:layout_weight="1"
             android:layout_marginTop="0dp"
             android:adjustViewBounds="true"
            android:padding="5dp"
            android:scaleType="fitCenter"
            android:src="@drawable/contactbutton"
            android:text="  Contact" />

    </LinearLayout>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="20dp"
        android:orientation="horizontal">

        <ImageButton

            android:id="@+id/button10"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_alignTop="@+id/button8"
            android:layout_marginRight="5dp"
            android:layout_marginLeft="2dp"
            android:layout_weight="1"
             android:layout_marginTop="0dp"
             android:adjustViewBounds="true"
            android:padding="5dp"
            android:scaleType="fitCenter"
            android:src="@drawable/routebutton"
            android:text="Route" />

        <ImageButton

            android:id="@+id/button10"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_alignTop="@+id/button8"
            android:layout_marginRight="5dp"
            android:layout_marginLeft="2dp"
            android:layout_weight="1"
             android:layout_marginTop="0dp"
             android:adjustViewBounds="true"
            android:padding="5dp"
            android:scaleType="fitCenter"
            android:src="@drawable/meningbutton"
            android:text="Uw mening" />

        <ImageButton

            android:id="@+id/button10"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_alignTop="@+id/button8"
            android:layout_marginRight="5dp"
            android:layout_marginLeft="2dp"
            android:layout_weight="1"
             android:layout_marginTop="0dp"
             android:adjustViewBounds="true"
            android:padding="5dp"
            android:scaleType="fitCenter"
            android:src="@drawable/vriendenbutton"
            android:text="Word vriend" />

    </LinearLayout>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginTop="10dp"
        android:orientation="horizontal">

        <ImageButton

            android:id="@+id/button10"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_alignTop="@+id/button8"
            android:layout_marginRight="5dp"
            android:layout_marginLeft="2dp"
            android:layout_weight="1"
             android:layout_marginTop="0dp"
             android:adjustViewBounds="true"
            android:padding="5dp"
            android:scaleType="fitCenter"
            android:src="@drawable/foldersbutton"
            android:text="Folders" />

        <ImageButton

            android:id="@+id/button10"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_alignTop="@+id/button8"
            android:layout_marginRight="5dp"
            android:layout_marginLeft="2dp"
            android:layout_weight="1"
             android:layout_marginTop="0dp"
             android:adjustViewBounds="true"
            android:padding="5dp"
            android:scaleType="fitCenter"
            android:src="@drawable/specialistenbutton"
            android:text="Specialisten" />

        <ImageButton

            android:id="@+id/button10"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_alignTop="@+id/button8"
            android:layout_marginRight="5dp"
            android:layout_marginLeft="2dp"
            android:layout_weight="1"
             android:layout_marginTop="0dp"
             android:adjustViewBounds="true"
            android:padding="5dp"
            android:scaleType="fitCenter"
            android:src="@drawable/bwcbutton"
            android:text="Brandwond  encentrum" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginTop="30dp"
        android:orientation="horizontal">

        <ImageButton

            android:id="@+id/button10"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_alignTop="@+id/button8"
            android:layout_marginRight="5dp"
            android:layout_marginLeft="2dp"
            android:layout_weight="1"
             android:layout_marginTop="0dp"
             android:adjustViewBounds="true"
            android:padding="5dp"
            android:scaleType="fitCenter"
            android:src="@drawable/nieuwsbutton"
            android:text="Nieuws en Agenda" />
     </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginTop="30dp"
        android:layout_marginBottom="40dp"
        android:orientation="horizontal">

        <ImageButton

            android:id="@+id/button10"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_alignTop="@+id/button8"
            android:layout_marginRight="5dp"
            android:layout_marginLeft="2dp"
            android:layout_weight="1"
             android:layout_marginTop="0dp"
             android:adjustViewBounds="true"
            android:padding="5dp"
            android:scaleType="fitCenter"
            android:src="@drawable/afspraakbutton"
            android:text="Facebook" />

        <ImageButton

            android:id="@+id/button10"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_alignTop="@+id/button8"
            android:layout_marginRight="5dp"
            android:layout_marginLeft="2dp"
            android:layout_weight="1"
             android:layout_marginTop="0dp"
             android:adjustViewBounds="true"
            android:padding="5dp"
            android:scaleType="fitCenter"
            android:src="@drawable/afspraakbutton"
            android:text="Youtube" />

        <ImageButton

            android:id="@+id/button10"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_alignTop="@+id/button8"
            android:layout_marginRight="5dp"
            android:layout_marginLeft="2dp"
            android:layout_weight="1"
             android:layout_marginTop="0dp"
             android:adjustViewBounds="true"
            android:padding="5dp"
            android:scaleType="fitCenter"
            android:src="@drawable/afspraakbutton"
            android:text="Twitter" />

        <ImageButton

            android:id="@+id/button10"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_alignTop="@+id/button8"
            android:layout_marginRight="5dp"
            android:layout_marginLeft="2dp"
            android:layout_weight="1"
             android:layout_marginTop="0dp"
             android:adjustViewBounds="true"
            android:padding="5dp"
            android:scaleType="fitCenter"
            android:src="@drawable/afspraakbutton"
            android:text="LinkedIn" />

    </LinearLayout>


</LinearLayout>
</LinearLayout>

Upvotes: 0

Views: 28

Answers (2)

Talha Mir
Talha Mir

Reputation: 1258

Instead of using FrameLayout use RelativeLayout and align the view to the top. Also set ImageView scale type to fitStart. Something like this:

       <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    <ImageView
        android:id="@+id/imageButton1"
        android:layout_width="40dp"
        android:layout_height="50dp"
        android:layout_marginBottom="20dp"
        android:layout_marginRight="40dp"
        android:layout_marginTop="10dp"
        android:layout_gravity="right" 
        android:src="@drawable/informatiebutton" />

    <ImageView
        android:layout_alignParentTop="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scaleType="fitStart"
        android:src="@drawable/logoversiejuni" />

 </RelativeLayout>

Upvotes: 1

Sush
Sush

Reputation: 3874

try below code

<ImageView
    android:layout_marginBottom="20dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scaleType="fitXY"
    android:layout_marginLeft="1dp"
    android:layout_marginTop="1dp"
    android:src="@drawable/logoversiejuni" />

Upvotes: 0

Related Questions