小编A. *_*brg的帖子

drawable.setColorFilter 标记为已弃用

编译器告诉我 setColorFilter 已被弃用!

 tab?.icon?.setColorFilter(
                ContextCompat.getColor(requireActivity(), R.color.colorLogoGrey),
                PorterDuff.Mode.SRC_IN
            )
Run Code Online (Sandbox Code Playgroud)

android drawable android-viewpager kotlin android-tablayout

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

如何使选项卡在撰写中可滚动

我想添加动态选项卡项目。以可滚动的方式,而不是固定的选项卡

我在这里遵循这个例子

但是在我实现相同之后,选项卡仍然固定,我想要的是显示选项卡的白色文本(不是固定大小的选项卡),并且选项卡必须是可滚动的,如下图所示

在此输入图像描述

我尝试使 TabRaw 可滚动,如下所示:

 TabRow(
    selectedTabIndex = pagerState.currentPage,
    backgroundColor = Color.Transparent,
    modifier = Modifier
        .fillMaxWidth()
        .padding(MaterialTheme.spacing._20sdp)
        .horizontalScroll(scrollableState)
        .height(32.dp),
    contentColor = colorResource(id = R.color.primary)
)
Run Code Online (Sandbox Code Playgroud)

但它抛出 IllegalArgumentException,因为我将它包含在 ConstraintLayout 中

tabs android kotlin android-jetpack-compose

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

ApplicationVariant、BaseVariantOutput 已弃用

我在 Android 应用程序项目的 Kotlin Dsl 文件中使用以下简化配置。

    class ApplicationVariantAction : Action<ApplicationVariant> {
    override fun execute(variant: ApplicationVariant) {
        val fileName = createFileName(variant)
        variant.outputs.all(VariantOutputAction(fileName))
    }

    private fun createFileName(variant: ApplicationVariant): String {
        return "Android" +
                "_${variant.name}" +
                "_${variant.flavorName}" +
                "_${variant.buildType}" +
                "_${variant.versionName}" +
                "_${variant.versionCode}" +
                "_${getDateTimeFormat()}.apk"
    }

    private fun getDateTimeFormat(): String {
        val simpleDateFormat = SimpleDateFormat("yyMdHms", Locale.US)
        return simpleDateFormat.format(Date())
    }

    class VariantOutputAction(
        private val fileName: String
    ) : Action<BaseVariantOutput> {
        override fun execute(output: BaseVariantOutput) {
            if (output is BaseVariantOutputImpl) {
                output.outputFileName = fileName
            } …
Run Code Online (Sandbox Code Playgroud)

gradle kotlin android-studio build.gradle gradle-kotlin-dsl

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