zoukankan      html  css  js  c++  java
  • 调用布局View的performClick()方法

    修改之前的xml片段。

                <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                    android:id="@+id/layout_deletesms"
                    android:clickable="true"
                    android:padding="0dip"
                    android:background="@drawable/sms_dialog_button"
                    android:layout_width="50dip"
                    android:layout_height="match_parent" >
                    <ImageView
                        android:id="@+id/deleteSms"
                        android:layout_centerInParent="true"
                        android:src="@drawable/sms_delete"
                        android:scaleType="centerInside"
                        android:focusable="false" // 仅仅这样设置无法实现所需效果。
                        android:background="#00000000"
                        android:layout_width="30dip"
                        android:layout_height="30dip"/>
                 </RelativeLayout>
    实现效果:点击ImageView时,ImageView的容器对象RelativeLayout,也有被点击的效果出现。

    这里,布局被点击时的效果是,切换不同的drawable图片。

    在xml布局文件中,无论怎么改都达不到效果。

    最后采取在代码中实现。当点击ImageView时,调用布局View的performClick()方法。

                <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                    android:id="@+id/layout_deletesms"
                    android:clickable="true"
                    android:padding="0dip"
                    android:background="@drawable/sms_dialog_button"
                    android:layout_width="50dip"
                    android:layout_height="match_parent" >
                    <ImageView
                        android:id="@+id/deleteSms"
                        android:layout_centerInParent="true"
                        android:src="@drawable/sms_delete"
                        android:scaleType="centerInside"
                        android:background="#00000000"
                        android:layout_width="30dip"
                        android:layout_height="30dip"/>
                 </RelativeLayout>

    mLayoutDelsms = (RelativeLayout) findViewById(R.id.layout_deletesms);

    case R.id.deleteSms:
        mLayoutDelsms.performClick();

  • 相关阅读:
    vue3 中的路由传参
    js还原底层简单的history路由
    js还原底层简单的hash路由
    使用proxy以及Reflect还原vue3中的shallowReadonly 与 readonly响应式的原理
    flex布局兼容浏览器处理
    使用proxy以及Reflect还原vue3中的shallowReactive与reactive响应式的原理
    TS学习笔记--其他(声明文件、内置对象)
    TS学习笔记--泛型
    TS学习笔记--函数
    springboot+mybatis-plus快速精简配置
  • 原文地址:https://www.cnblogs.com/fengzhblog/p/3198983.html
Copyright © 2011-2022 走看看