【问题标题】:edit layout of existing child in RelativeLayout在 RelativeLayout 中编辑现有子项的布局
【发布时间】:2013-11-11 21:14:55
【问题描述】:

我有一个带有许多孩子的 RelativeLayout。 RelativeLayout 是我活动的主要布局。我需要向其中一个孩子添加布局值layout_alignParentBottom="true"。我需要以编程方式执行此操作。链接How to set the android property layout_alignParentBottom to a button dynamically 对我不起作用,因为基本上我不想膨胀RelativeLayout,因为我已经在setContentView(...) 拥有它。任何想法如何做到这一点?

【问题讨论】:

  • 您是在RelativeLayout 视图组上添加带有addView 的子视图吗?
  • @akhalsa 我想通了。

标签: android android-layout android-relativelayout


【解决方案1】:

我想通了:

RelativeLayout.LayoutParams layout = (LayoutParams) theChild.getLayoutParams();
layout.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-15
    相关资源
    最近更新 更多