I have a layout that uses a scroll view. The first part of the text in the scroll view is cut off in the emulator and on an HTC phone the scroll view scrolls way past the end of the text and it takes a lot of scrolling to get back to the text.
Eclipse complains that “This ScrollView layout or its LinearLayout parent is useless” and I suspect that this message is the main culprit for my woes but am happy to be corrected
The layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/Container"
android:id="@+id/about">
<ScrollView style="@style/Content">
<TextView style="@style/Content"
android:id="@+id/about_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/about_text" />
</ScrollView>
</LinearLayout>
The styles
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MainTheme">
<item name="android:textColor">@color/txtColor</item>
</style>
<style name="ApplicationTheme" parent="android:Theme">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:colorBackground">@color/mnuColor</item>
<item name="android:textColor">@color/txtColor</item>
</style>
<style name="Container" parent="ApplicationTheme">
<item name="android:textColor">@color/txtColor</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:colorBackground">@color/mnuColor</item>
</style>
<style name="Webview" parent="Container">
<item name="android:background">@drawable/web_background_image</item>
<item name="android:windowBackground">@drawable/background_image</item>
<item name="android:colorBackground">@color/mnuColor</item>
</style>
<style name="MyPlaceDialog" parent="@android:style/Theme.Dialog">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:orientation">vertical</item>
<item name="android:stretchColumns">*</item>
</style>
<style name="Content">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_gravity">center</item>
</style>
<style name="button" parent="@android:style/Widget.Button">
<item name="android:background">@drawable/button</item>
<item name="android:layout_marginTop">2dp</item>
<item name="android:layout_marginBottom">3dp</item>
<item name="android:layout_marginLeft">4dp</item>
<item name="android:layout_marginRight">4dp</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
</style>
</resources>
Androids documentation is utterly appallingly useless in helping to explain why a layout might be useless and eclipse is no better so any ideas on what I need to do to fix this problem are greatly appreciated
Your linear layout is housing only a single view. Because of this, your LinearLayout can be eliminated and the ScrollView can be made the root element for your layout.
Note that lint isn’t always 100% accurate. While its correct that you can remove the view, its not always something you desire or need to do.