ScrollView似乎为其子

时间:2018-04-09 19:07:08

标签: android android-layout scrollview

我遇到ScrollView的问题,似乎为其子女增加了一个上限。我上方有一个LinearLayout,它设置了上边距,以便布局低于其他元素(其父级为FrameLayout),然后将ScrollView插入LinearLayout },最后一个孩子被附加到ScrollView

下图显示了" border"之间出现的空白区域。和订单详情(TextView): Image

Java代码:

// Inner layout to accommodate ScrollView
    LinearLayout inner_layout = new LinearLayout(app.getApplicationContext());
    LinearLayout.LayoutParams inner_params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 440);
    inner_params.setMargins(0, 135, 0, 0);
    inner_layout.setLayoutParams(inner_params);

    // ScrollView for details of the order (in case everything doesn't fit in the body)
    ScrollView scrollView = new ScrollView(app.getApplicationContext());
    params_in = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    scrollView.setLayoutParams(params_in);
    scrollView.setFillViewport(false);

    TextView body_text = new TextView(app.getApplicationContext());
    params_in = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params_in.setMargins(10, 0, 10, 10);
    body_text.setLayoutParams(params_in);
    body_text.setTextColor(getResources().getColor(R.color.colorTextSecondary, null));

对于ScrollView的孩子来说,几乎就像135的上边距一样。

如果有人能帮助我理解我做错了什么,我会非常感激。

0 个答案:

没有答案