我正在使用嵌套在 ScrollView 中的 TextView。滚动工作正常,但 ScrollView 似乎在 TextView 的顶部添加了一个额外的填充,如下所示:
<ScrollViewTop>
<Padding>
<TextViewTop>
<TextViewContent>
<TextViewBottom>
<ScrollViewBottom>
请注意,这只发生在 TextView 的顶部,并且空间是静态的,滚动时不会移动。这是我在 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>
这是包含布局的片段:
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;
}
}
如何强制 TextView 占据整个 ScrollView 区域?