小编Thi*_*ice的帖子

如何在右边缘水平ListView添加模糊效果以显示还有更多内容

我想要一种让用户看到他们可以在我的水平 ListView 上水平滚动的方法

提前致谢

编辑:

这是我的代码@wcyankees424

Container(
  height: 50,
  child: Stack(
    children: <Widget>[
      ListView.builder(
          scrollDirection: Axis.horizontal,
          shrinkWrap: true,
          itemCount: cheat.buttons.length,
          itemBuilder: (context, index) {
            return ButtonListItem(cheat.buttons[index]);
          }
      ),
      Positioned(
        top: 0,
        right: 0,
        width: 50,
        height: MediaQuery.of(context).size.height,
        child: ClipRRect(
          child: BackdropFilter(
            filter: ImageFilter.blur(
                sigmaX: 0,
                sigmaY: 99
            ),
            child: Container(
              color: Colors.black.withOpacity(0.1),
            ),
          ),
        ),
      )
    ],
  )
),
Run Code Online (Sandbox Code Playgroud)

这是它现在的样子: 在此输入图像描述

android dart flutter flutter-layout

2
推荐指数
1
解决办法
4581
查看次数

Android ConstraintLayout 中心与多个按钮水平对齐

我最近开始在 android studio 中使用 ConstraintLayout(稍后可能会在我的应用程序中使用它),我想创建一个布局,在一行中有 5 个按钮,并且有 10 行 5 个按钮。我做对了,只是我希望按钮在填充整行时全部调整为相同的宽度(按钮之间没有间隙)。

问题的一个例子:

我当前的 xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout     xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="lotterynumbergenerator.johnferrazlopez.com.southafricanlotteryguide.other.SaveNumbers">

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="01"
        android:textStyle="bold"
        app:layout_constraintHorizontal_chainStyle="spread_inside"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toLeftOf="@+id/button2"
        tools:layout_editor_absoluteY="16dp" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="02"
        android:textStyle="bold"
        app:layout_constraintLeft_toRightOf="@+id/button"
        app:layout_constraintRight_toLeftOf="@+id/button3"
        tools:layout_editor_absoluteY="16dp" />

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="03"
        android:textStyle="bold"
        app:layout_constraintLeft_toRightOf="@+id/button2"
        app:layout_constraintRight_toLeftOf="@+id/button4"
        tools:layout_editor_absoluteY="16dp" />

    <Button
        android:id="@+id/button4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="04"
        android:textStyle="bold"
        app:layout_constraintLeft_toRightOf="@+id/button3"
        app:layout_constraintRight_toLeftOf="@+id/button5"
        tools:layout_editor_absoluteY="16dp" />

    <Button
        android:id="@+id/button5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="05"
        android:textStyle="bold"
        app:layout_constraintLeft_toRightOf="@+id/button4"
        app:layout_constraintRight_toRightOf="parent"
        tools:layout_editor_absoluteY="16dp" />

    <Button
        android:id="@+id/button6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="06" …
Run Code Online (Sandbox Code Playgroud)

android android-constraintlayout

1
推荐指数
1
解决办法
7224
查看次数

Kotlin RecyclerView Adapter 多个回调函数

如何将多个回调函数返回到 RecyclerView 的 Activity/Fragment?

我对 RecyclerView 中的每个项目都有多个选项(编辑、删除、CheckedAsComplete、视图),并且我希望在 RecyclerView 的 Activity/Fragment 中为每个项目提供回调函数。

以下是我如何在适配器中获得回调的链接:https://www.geeksforgeeks.org/kotlin-lambda-functions-for-recyclerview-adapter-callbacks-in-android/

我只需要知道适配器中是否可以有多个回调,如果可以,我该如何实现它?

我的活动的适配器代码:

val adapter = ProductAdapter(this) {
    deleteProduct(it),
    editProduct(it),
    viewProduct(it),
    checkAsComplete(it)
}
Run Code Online (Sandbox Code Playgroud)

这是我的适配器的构造函数:

class ProductAdapter(
    private var context: Context,
    private val deleteProduct: (ItemTable) -> Unit,
    private val editProduct: (ItemTable) -> Unit,
    private val viewProduct: (ItemTable) -> Unit,
    private val checkedAsComplete: (ItemTable) -> Unit
): RecyclerView.Adapter<ProductAdapter.ItemProductViewHolder>() {
    // Rest of RecyclerView Adapter Code
}
Run Code Online (Sandbox Code Playgroud)

我对 kotlin 还很陌生,所以我非常感谢您的帮助!

android kotlin android-recyclerview

1
推荐指数
1
解决办法
1269
查看次数