如何以编程方式设置相对布局中按钮的layout_align属性?

时间:2016-11-04 10:30:03

标签: android

1 个答案:

答案 0 :(得分:1)

尝试添加此

    android:layout_alignParentRight="true"
    android:layout_alignParentBottom="true"

这是代码

    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    TextView textView = new TextView(this);
    textView.setLayoutParams(layoutParams);