控件的invisible特性和父级控件的关系

在一个项目中,我设置了控件的invisible特性,

最初的时候,我在全局的ConstraintLayout下面写了textView,可以顺利实现控件的显示和隐藏

后来把textView用了一个ContraintLayout包裹一层,

<android.support.constraint.ConstraintLayout
        android:id="@+id/controller_view"
        android:layout_width="match_parent"
        android:layout_height="@dimen/camera_controller_height"
        android:background="@drawable/camera_controller_bg"
        android:clickable="true"
        android:padding="6dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent">

        <android.support.constraint.ConstraintLayout
            android:id="@+id/controller_viewpoint"
            android:layout_width="match_parent"
            android:layout_height="47dp"
            android:layout_marginLeft="84dp"
            android:layout_marginTop="14dp"
            android:layout_marginRight="33dp"
            android:visibility="gone"
            android:background="@mipmap/ic_controller_viewpoint_background"
            android:overScrollMode="never"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toBottomOf="parent">

            <TextView
                android:id="@+id/tv_point1"
                android:layout_width="wrap_content"
                android:layout_height="24dp"
                android:layout_marginLeft="6dp"
                android:background="@drawable/camera_bg_selecte_blue"
                android:gravity="center"
                android:paddingLeft="12dp"
                android:paddingRight="12dp"
                android:text="低吸高抛"
                android:textColor="@color/camera_select_color"
                android:textSize="@dimen/camera_small_size"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

        </android.support.constraint.ConstraintLayout>

当我使用viewpoint.visible = View.GONE 的时候,下面的textView不能完全消失,会留下一个背景小圆圈。

后来我发现,是因为我使用  

fullControllerViewSet.setVisibility(view.id, view.visibility)

 这行代码,把这个textView和最外层的约束性布局ContraintLayout绑定在一起,由于后来又包裹了一层,这个绑定关系就消失了。当我使用viewpoint.visible = View.GONE的时候,viewpoint布局下面的textview不会起作用。

必须给textview设置invisible属性

tv_point1.visibility = View.INVISIBLE
细节问题,必须注意。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值