【问题标题】:How to remove ImageView alignment programmatically?如何以编程方式删除 ImageView 对齐?
【发布时间】:2014-07-22 10:57:53
【问题描述】:
<ImageView 
        android:id="@+id/wipeID"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/popup_window"
        android:layout_alignBottom="@+id/linerID"
        android:src="@drawable/wiper_btn"/>

在上面的一个 android:layout_alignBottom="@+id/linerID" 是删除编程如何删除那个?

【问题讨论】:

  • 无法理解...请您详细解释一下
  • 在执行 onclick 之前我想要这两个对齐 android:layout_above="@+id/popup_window" android:layout_alignBottom="@+id/linerID" 但是在执行 onclick 之后我需要删除这个 android: layout_alignBottom="@+id/linerID" 以编程方式如何做到这一点请帮助我。
  • OK.. 你的意思是隐藏一些视图?
  • 是的,该怎么做。

标签: android layout


【解决方案1】:

尝试使用这个: imageView.setBaselineAlignBottom(false);

【讨论】:

    【解决方案2】:

    如果我没有误会你想改变你的布局参数...

    所以这大概是你可以实现它的方法:

    1. 使用 findViewById(...) 获取您的图像视图
    2. 以某种方式获取布局参数,如下所示: LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) imageView.getLayoutParams();
    3. 通过设置所需的值来更改它们: params.setMargins(newX, newY, 0, 0); //用于边距 imageView.setLayoutParams(params); 如果这不起作用(不存在对齐底部的参数),您可以添加规则: this could helpgoogle 类似“android 添加规则布局参数”

    希望这会引导您走上正确的道路...

    【讨论】:

      猜你喜欢
      • 2014-08-12
      • 2013-10-08
      • 2019-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多