For some reason, I’m having difficulty aligning ImageView’s to the top of the activities in my Android applications. For example:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:scaleType="fitStart"
android:src="@drawable/myImage" />
<ListView android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
I was able to get the ImageView to align to the top of the activity with “fitStart”, but without that then the imageView wouldn’t be all the way at the top. Now that the ImageView is on top, the ListView isn’t directly below it. Instead, it is a quarter of the screen down. This is happening on all of my activities, even ones without ListView’s.
As a side note, I did remove the system title bars from my activities in AndroidManifest. However, even when I add them back in, the problem is still occurring.
Any ideas?
Fixed by using RelativeLayout’s