小编ken*_*y_k的帖子

更改重叠视图下的图像的色彩颜色

我有一个滚动视图,其中包含很多图像。我想实现一个高亮区域,该区域会更改其下方所有视图的颜色(仅该区域下方的部分视图)

在此处输入图片说明

这是布局,vOverlayColor是我要设置覆盖颜色的视图。

<androidx.constraintlayout.widget.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <ImageView
                android:layout_width="100dp"
                android:layout_height="wrap_content"
                android:layout_margin="@dimen/spacing_large"
                android:adjustViewBounds="true"
                android:src="@drawable/ic_delete"
                android:tint="@color/colorGreyDark"
                tools:ignore="ContentDescription" />

            <ImageView
                android:layout_width="100dp"
                android:layout_height="wrap_content"
                android:layout_margin="@dimen/spacing_large"
                android:adjustViewBounds="true"
                android:src="@drawable/ic_delete"
                android:tint="@color/colorGreyDark"
                tools:ignore="ContentDescription" />

            <ImageView
                android:layout_width="100dp"
                android:layout_height="wrap_content"
                android:layout_margin="@dimen/spacing_large"
                android:adjustViewBounds="true"
                android:src="@drawable/ic_delete"
                android:tint="@color/colorGreyDark"
                tools:ignore="ContentDescription" />

            <ImageView
                android:layout_width="100dp"
                android:layout_height="wrap_content"
                android:layout_margin="@dimen/spacing_large"
                android:adjustViewBounds="true"
                android:src="@drawable/ic_delete"
                android:tint="@color/colorGreyDark"
                tools:ignore="ContentDescription" />

            <ImageView
                android:layout_width="100dp"
                android:layout_height="wrap_content"
                android:layout_margin="@dimen/spacing_large"
                android:adjustViewBounds="true"
                android:src="@drawable/ic_delete"
                android:tint="@color/colorGreyDark"
                tools:ignore="ContentDescription" />
        </LinearLayout>
    </ScrollView>

    <View
        android:id="@+id/vOverlayColor"
        android:layout_width="match_parent"
        android:layout_height="120dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

你有什么建议吗?

android android-layout android-view android-constraintlayout

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

RxJava在空时发出错误

如果Observable在完成之前没有发出一个值,我想"抛出"自定义错误.

让我试着举个例子:

Observable<SomeClass> stream = ...

stream
.filter(...)
.singleOrError(new MyCustomException())
Run Code Online (Sandbox Code Playgroud)

所以我有一个SomeClass对象流.如果fitler()不发出一个元素,我想发出自定义错误.

error-handling exception rx-java rx-java2

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

configuration.setLocale(locale)与AppCompatDelegate.setDefaultNightMode不兼容

如果我将darkmode设置为,AppCompatDelegate.setDefaultNightMode而系统不是黑暗的,则Configuration.setLocale无法使用。我将语言环境更改为,例如,从更改En为It,所有字符串仍然以系统语言显示。

如果我设置了与系统(Android 10)相同的NightMode,则没有问题。android 9或更低版本存在相同的问题:如果我在应用中设置了暗模式,并且更改了上下文语言,则活动会根据系统的语言显示文本。

android setlocale android-10.0 android-dark-theme

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

科特林。尝试使用具体化类型来解析列表和数组

我尝试在解析 json 时使用具体化类型。它可以完美地处理单个 json 条目,但无法处理列表。

问题:

  1. String.parseList() 方法中缺少什么?
  2. 尽管赋值提前通过了一行,但为什么在 .first() 上出现 ClassCastException?
    package qa

    import com.fasterxml.jackson.databind.ObjectMapper
    import org.slf4j.LoggerFactory
    import org.testng.Assert
    import org.testng.annotations.Test

    class ReifiedParseListTest {

        data class User(var name: String = "userName", var age: Int = 0)

        val log = LoggerFactory.getLogger(this.javaClass.name)
        val objectMapper = ObjectMapper()
        val json: String = """[{"name":"Alice","age":1},{"name":"Bob","age":2}]"""
        val expected: String = "[User(name=Alice, age=1), User(name=Bob, age=2)]"


        inline fun <reified V> String.parseList(): List<V> = objectMapper
                .readValue(this, Array<V>::class.java).toList()


        @Test
        fun checkParseList_OK() {
            val actual: List<User> = objectMapper
                    .readValue(json, Array<User>::class.java).toList()

            log.info("actual.first() …
Run Code Online (Sandbox Code Playgroud)

kotlin kotlin-reified-type-parameters

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

spring-data-redis multiGet 如何处理缓存未命中?

我正在使用 Redis 缓存(通过 Jedis 客户端),并且我想使用ValueOperations#multiGet,它接受一个Collection键,并List以相同的顺序从缓存中返回一个对象。我的问题是,当某些键在缓存中而其他键不在缓存中时会发生什么?我知道在下面使用了Redis MGET,它将返回nil不在缓存中的任何元素。

我找不到任何有关如何ValueOperations解释此响应的文档。我认为他们会的null,并且肯定可以测试它,但是围绕未记录的行为构建一个系统是危险的。

为了完整起见,以下是缓存客户端的配置方式:

@Bean
public RedisConnectionFactory redisConnectionFactory() {
    JedisConnectionFactory redisConnectionFactory = new JedisConnectionFactory();

    redisConnectionFactory.setHostName(address);
    redisConnectionFactory.setPort(port);

    redisConnectionFactory.afterPropertiesSet();
    return redisConnectionFactory;
}

@Bean
public ValueOperations<String, Object> someRedisCache(RedisConnectionFactory cf) {
    RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
    redisTemplate.setConnectionFactory(cf);
    redisTemplate.setDefaultSerializer(new GenericJackson2JsonRedisSerializer());
    redisTemplate.afterPropertiesSet();
    return redisTemplate.opsForValue();
}
Run Code Online (Sandbox Code Playgroud)

我在用spring-data-redis:2.1.4

那么,是否有任何相关文档或可靠的事实来源?

redis jedis spring-data spring-data-redis spring-boot

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

如何使用css Only选择"选择文件"按钮的样式

友.

我想尝试设计一下:

<input type="file" multiple>
Run Code Online (Sandbox Code Playgroud)

想要我想:我想改变它的颜色,也改变它的大小......

提前致谢.

html css

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

在 ConstraintLayout 中,当没有 `weight` 属性时, android:layout_width="0dp" 是什么意思?

我有这样的布局:

<android.support.constraint.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/ThemeOverlayGoogleMaterialIcons">

  <LinearLayout
      android:layout_height="wrap_content"
      android:layout_width="0dp">

...
Run Code Online (Sandbox Code Playgroud)

android:layout_width="0dp"不属于 的孩子 是什么意思LinearLayout?

android:layout_width="0dp"没有属性的时候是什么意思weight?

android android-layout-weight android-constraintlayout

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

Spring boot:违反引用完整性约束

您好,我遇到了这个错误,我找到的解决方案都不起作用。我有一个购物车实体:

@Data
@Entity
public class Cart {
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Long id;
  private String status;
  @ManyToOne(cascade = CascadeType.MERGE)
  @JoinColumn(name = "usr_id", nullable = false)
  private User usr;
  @ElementCollection(targetClass=String.class)
  private List<String> productsBarcode = new ArrayList<>();
  private long nutritional_score;
}
Run Code Online (Sandbox Code Playgroud)

和一个 User 实体

@Entity
@Data
public class User {
    @Id
    @GeneratedValue
    private Long id;
    private String firstname;
    private String lastname;
    private String email;
    private String phone;
    @JsonIgnore
    @OneToMany(mappedBy = "id",cascade=CascadeType.ALL)
    private List<Cart> carts = new ArrayList<Cart>();
}
Run Code Online (Sandbox Code Playgroud)

当我尝试使用以下 JSON 传递 …

hibernate-mapping spring-data-jpa spring-boot

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