滚动型增加了顶部额外的空间 [英] ScrollView adds extra space on top
问题描述
我使用嵌套在一个滚动型内一个TextView。滚动工作正常,但滚动型似乎在看起来像这样TextView的顶部添加一个微胖:
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>
请注意,这仅发生在TextView的顶部并且该空间是静态的,滚动时不移动。这是我使用的是DialogFragment里面的布局:
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>
这是包含布局片段:
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占用整个滚动型区域?
How can I force the TextView to take up the entire ScrollView area?
推荐答案
这个问题得到了解决这里:
The problem got solved here:
<一个href=\"http://stackoverflow.com/questions/18465002/layout-margin-padding-at-the-top-of-dialog-fragment\">Layout缘/填充在对话片段顶部
问题是它可以通过设置去除窗口标题
The problem was the window title which can be removed by setting:
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
这篇关于滚动型增加了顶部额外的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!