0

I am using a TextView nested inside a ScrollView. Scrolling works fine, but the ScrollView seems to add an extra padding on the top of the TextView that looks like this:

<ScrollViewTop>
<Padding>
<TextViewTop>
<TextViewContent>
<TextViewBottom>
<ScrollViewBottom>

enter image description here

Note that this only happens at the top of the TextView and that the space is static, does not move when scrolling. This is the layout I am using inside a DialogFragment:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true" 
    android:fadingEdge="none"
    android:orientation="vertical" >

        <TextView
        android:id="@+id/textViewHelp"
        android:adjustViewBounds="true"
        android:scrollbars = "vertical"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>
</ScrollView>

And here is the Fragment that contains the layout:

public class HelpDialogFragment extends DialogFragment {

    public interface HelpDialogFragmentListener {
        void onFinishHelpDialogFragment(String inputText);
    }

    //empty constructor for fragment (android requirement)
    public HelpDialogFragment() {

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.help_fragment, container);
        TextView tv = (TextView) view.findViewById(R.id.textViewHelp);
        tv.setText(Html.fromHtml(Utils.loadHtmlFromResources(getActivity(), R.raw.help)));
        return view;
    }
}

How can I force the TextView to take up the entire ScrollView area?

Herr von Wurst
  • 2,571
  • 5
  • 32
  • 53

2 Answers2

1

You only need this for your ScrollView:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <TextView
        android:id="@+id/textViewHelp"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>
</ScrollView>

I entered your code in my xml. There was no padding.

  • Weird, this is what I came from and I still get the padding. I added a screenshot from what I get with your xml. – Herr von Wurst Aug 21 '13 at 16:02
  • As for the padding. I think what the problem is the Text you're adding to the TextView might itself have Space at the front of title. Check the text –  Aug 21 '13 at 16:31
  • No, the text is fine, the same problem occurs, when I use say an ImageView instead of the TextView. – Herr von Wurst Aug 26 '13 at 16:57
1

The problem got solved here:

Layout margin/padding at the top of dialog fragment

The problem was the window title which can be removed by setting:

getWindow().requestFeature(Window.FEATURE_NO_TITLE);
Community
  • 1
  • 1
Herr von Wurst
  • 2,571
  • 5
  • 32
  • 53