0

im with a problem related to android UI Design.

This is what i want: http://i.imgur.com/a7DLo4x.jpg

This is what i have: http://i.imgur.com/AnL3cHT.jpg

I found a smiliar post about this, but their solution didnt help me: Android background Image to fill screen

This is my XML code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:alwaysDrawnWithCache="false">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/imageView"
        android:scaleType="center"
        android:background="@drawable/bg" />


   <!-- <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/logoImage"
        android:layout_gravity="center_horizontal"
        android:background="@drawable/logo"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" />
-->
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="30dp"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="Login"
        android:id="@+id/loginBt"
        android:layout_below="@+id/logoImage"
        android:layout_alignStart="@+id/logoImage"
        android:layout_marginTop="5dp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="30dp"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="Register"
        android:id="@+id/registerBt"
        android:layout_alignBottom="@+id/loginBt"
        android:layout_alignRight="@+id/loginBt"
        android:layout_alignEnd="@+id/logoImage"
        android:layout_marginTop="5dp" />

    <FrameLayout
        android:id="@+id/loginFragment"
        android:layout_width="fill_parent"
        android:layout_height="match_parent">

    </FrameLayout>



</RelativeLayout>

I also tried to use android:scaleType="centerCrop"

Thanks for your time.

Community
  • 1
  • 1
user3000019
  • 103
  • 1
  • 10

2 Answers2

1

you have android:scaleType="center"

you need android:scaleType="centerCrop"

1

I think you are using the wrong element to fill the ImageView. Please avoid using background element. Use src(source) element. It should then work fine.

 android:src
Keshav
  • 577
  • 3
  • 10