I am having trouble using ScrollView. For some strange reason, it is hiding the content to be displayed on the top. I tried giving margin, padding, etc. but nothing seems to work. This is my layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" android:background="@drawable/background">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:background="@drawable/titlebar"
android:id="@+id/titlebar">
<TextView android:layout_width="fill_parent" android:id="@+id/textView1"
android:layout_height="fill_parent" android:layout_gravity="center"
android:gravity="center" android:textColor="@color/white"
android:textSize="20dip" android:text="Help"></TextView>
</LinearLayout>
<ScrollView android:layout_height="wrap_content" android:id="@+id/scrollView1"
android:layout_width="fill_parent">
<LinearLayout android:orientation="vertical" android:id="@+id/linearLayout2"
android:gravity="center" android:layout_width="fill_parent"
android:layout_gravity="center" android:layout_height="fill_parent"
android:paddingLeft="10dip" android:paddingRight="5dip">
<ImageView android:layout_height="wrap_content"
android:src="@drawable/icon" android:layout_marginTop="10dip"
android:id="@+id/help_icon" android:layout_width="fill_parent"
android:layout_marginBottom="15dip"></ImageView>
<TextView android:layout_height="wrap_content"
android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed dapibus venenatis suscipit.\n\nCras lacus sem, cursus a dictum sed, condimentum quis urna. Ut vel metus lorem, quis semper lacus. Suspendisse eu urna massa, a blandit mi. "
android:id="@+id/help_text" android:layout_width="wrap_content"
android:textColor="@color/black" android:textSize="15dip"
android:paddingBottom="10dip"></TextView>
</LinearLayout>
</ScrollView>
</LinearLayout>
My image is getting hidden behind the top titlebar and only a small part of its bottom is visible in the device/emulator. It appears fine in Eclipse. I am using ADT11
Thanks in advance!
Hi I had the same problem, and after investigation I have found the solution, and in your XML code I can see that you are doing the same mistake in layout.
The problem is that you are setting the ScrollView child (LinearLayout) layout_gravity to center. Remove this line and it should work for you.
android:layout_gravity="center" //remove this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With