android:persistentDrawingCache="animation"

Defines the persistence of the drawing cache. The drawing cache might be enabled by a ViewGroup for all its children in specific situations (for instance during a scrolling.) This property lets you persist the cache in memory after its initial usage. Persisting the cache consumes more memory but may prevent frequent garbage collection is the cache is created over and over again. By default the persistence is set to scrolling.

大致意思如下:

  定义绘图的高速缓存的持久性。 绘图缓存可能由一个 ViewGroup 在特定情况下为其所有的子类启用,例如在一个滚动的过程中。 此属性可以保留在内存中的缓存后其初始的使用。 坚持缓存会消耗更多的内存,但可能会阻止频繁的垃圾回收是反复创建缓存。 默认情况下持续存在设置为滚动。

  其属性值只有以下几种:

  ConstantValueDescription

  none0x0The drawing cache is not persisted after use.

  animation0x1The drawing cache is persisted after a layout animation.

  scrolling0x2The drawing cache is persisted after a scroll.

  all0x3The drawing cache is always persisted.


<androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/listinfo" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/round_style" android:elevation="4dp" android:layout_margin="8dp" android:clickable="true" android:padding="10dp"> <com.xuexiang.xui.widget.textview.autofit.AutoFitTextView android:id="@+id/code" style="@style/item_show_title" android:layout_width="14dp" android:layout_height="16dp" android:paddingTop="2dp" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <com.xuexiang.xui.widget.textview.autofit.AutoFitTextView style="@style/item_show_title" android:id="@+id/name" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/code"/> <com.xuexiang.xui.widget.textview.autofit.AutoFitTextView style="@style/item_show_title" android:id="@+id/spec" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/name"/> <com.xuexiang.xui.widget.textview.autofit.AutoFitTextView style="@style/item_show_title" android:id="@+id/composition" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/spec"/> <com.xuexiang.xui.widget.textview.autofit.AutoFitTextView style="@style/item_show_title" android:id="@+id/weight" app:layout_constraintStart_toEndOf="@+id/composition" app:layout_constraintTop_toBottomOf="@+id/spec"/> <ImageView android:id="@+id/status" android:layout_width="wrap_content" android:layout_height="wrap_content" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@+id/name" app:layout_constraintTop_toTopOf="parent" /> <View style="@style/item_show" android:id="@+id/view_task_list" android:layout_width="match_parent" android:layout_height="1dp" android:background="#cccccc" android:layout_marginTop="3dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@+id/composition" app:layout_constraintStart_toStartOf="@+id/composition"/> </androidx.constraintlayout.widget.ConstraintLayout>点击表格,显示弹窗展示列内容
最新发布
06-04
要在点击表格时显示弹窗展示列内容,可以通过以下步骤实现: 1. 在布局文件中创建一个弹窗布局,例如: ```xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="16dp"> <TextView android:id="@+id/title" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Title" android:textSize="18sp" android:textStyle="bold" /> <TextView android:id="@+id/content" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Content" android:textSize="16sp" /> </LinearLayout> ``` 2. 在点击表格的事件中,获取列内容并设置到弹窗布局中,例如: ```java listinfo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // 获取列内容 String code = ((TextView) v.findViewById(R.id.code)).getText().toString(); String name = ((TextView) v.findViewById(R.id.name)).getText().toString(); String spec = ((TextView) v.findViewById(R.id.spec)).getText().toString(); String composition = ((TextView) v.findViewById(R.id.composition)).getText().toString(); String weight = ((TextView) v.findViewById(R.id.weight)).getText().toString(); // 创建弹窗布局 View popupView = getLayoutInflater().inflate(R.layout.popup_layout, null); // 获取弹窗布局中的控件 TextView titleView = popupView.findViewById(R.id.title); TextView contentView = popupView.findViewById(R.id.content); // 设置弹窗标题和内容 titleView.setText(name); contentView.setText("Code: " + code + "\n" + "Spec: " + spec + "\n" + "Composition: " + composition + "\n" + "Weight: " + weight); // 创建弹窗 PopupWindow popupWindow = new PopupWindow(popupView, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT); // 设置弹窗的背景和动画 popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); popupWindow.setAnimationStyle(R.style.PopupAnimation); // 显示弹窗 popupWindow.showAtLocation(v, Gravity.CENTER, 0, 0); } }); ``` 其中,R.layout.popup_layout 表示弹窗布局文件的名称,R.style.PopupAnimation 表示弹窗的动画样式。 3. 在 styles.xml 文件中定义弹窗的动画样式,例如: ```xml <style name="PopupAnimation" parent="android:Animation"> <item name="android:windowEnterAnimation">@anim/popup_enter</item> <item name="android:windowExitAnimation">@anim/popup_exit</item> </style> ``` 其中,@anim/popup_enter 和 @anim/popup_exit 表示进入和退出弹窗时的动画效果,可以根据需要自定义实现。 4. 在 res 目录下创建 anim 目录,并在该目录下创建 popup_enter.xml 和 popup_exit.xml 文件,实现弹窗进入和退出时的动画效果,例如: popup_enter.xml: ```xml <set xmlns:android="http://schemas.android.com/apk/res/android"> <scale android:fromXScale="0.0" android:fromYScale="0.0" android:toXScale="1.0" android:toYScale="1.0" android:pivotX="50%" android:pivotY="50%" android:duration="300" /> <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="300" /> </set> ``` popup_exit.xml: ```xml <set xmlns:android="http://schemas.android.com/apk/res/android"> <scale android:fromXScale="1.0" android:fromYScale="1.0" android:toXScale="0.0" android:toYScale="0.0" android:pivotX="50%" android:pivotY="50%" android:duration="300" /> <alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="300" /> </set> ``` 这样,当用户点击表格时,就会显示一个弹窗,展示列内容。需要注意的是,可以根据实际需求自定义弹窗布局和样式,以及实现更加复杂的动画效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值