文字不会出现在屏幕的底部

时间:2010-12-29 10:40:13

标签: android

嗨,虽然我已经给出了tParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,RelativeLayout.TRUE),为什么我的文字不会出现在底部? 这是我的代码请帮忙,

 footScroll_relative = new RelativeLayout(this);
    footScroll_scrollView = new ScrollView(this);
    footScroll_horizontalScrollView = new HorizontalScrollView(this);
    test_text = new TextView(this);

    footScroll_relative.setLayoutParams(new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT,android.view.ViewGroup.LayoutParams.FILL_PARENT));
    LayoutParams tParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    tParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    footScroll_horizontalScrollView.setLayoutParams(new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT,android.view.ViewGroup.LayoutParams.FILL_PARENT));
    footScroll_scrollView.setLayoutParams(tParams);

    test_text.setText("Ramesh ");

    footScroll_horizontalScrollView.addView(test_text);
    footScroll_scrollView.addView(footScroll_horizontalScrollView);
    footScroll_relative.addView(footScroll_scrollView);
    setContentView(footScroll_relative);

1 个答案:

答案 0 :(得分:0)

这是如何

的一个例子
TextView tView = ((TextView)view.findViewById(R.id.seekBarFilterLabel));
LayoutParams tParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
tParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
tView.setLayoutParams(tParams);

希望这有帮助

编辑:好吧,在你的previuos未经编辑的问题中你问如何在RelativaLayout父底部对齐文本,但是在这里你在Horizo​​ntalScrollView中添加TextView,这是不正确的,规则RelativeLayout.ALIGN_PARENT_BOTTOM仅在你有效时才有效在RelativeLayout中添加一个视图,而不是在ScrollView内部。