Question: I'm trying to learn `FrameLayout` from this `tutorial` 

<http://javatechig.com/android/android-framelayout-example>

it adds one `imageView` in `FrameLayout` and trying the image to be in center with 

```
    android:scaleType="centerCrop"

```

but it's not working   

Image shows like this   

[![image](https://i.stack.imgur.com/HUwiZ.png)](https://i.stack.imgur.com/HUwiZ.png)

here is activity\_main.xml

```
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scaleType="centerCrop"
        android:src="@drawable/ic_launcher" />

        </FrameLayout>

```

here is class file

```
public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

```

is it some new attribute that need to be replaced ??  

Image aligns well in relative layout but not in frame layout.Any suggestion ?

Answer: 
Set layout gravity to imageView.

```
 android:layout_gravity="center"

```

depends on your requirment you can give "layout\_gravity" like:

```
center_vertical or center_horizontal. 

```
`scaleType` is not mean the way image place in its father layout, but how to place the image inside its own boarder layout. see [ScaleType link](http://developer.android.com/reference/android/widget/ImageView.ScaleType.html)

If you want to adjust the alignment like left , bottom or center, you can use `android:layout_gravity` in the ImageView or set `android:gravity` in it's father layout.