Android BottomSheetDialogFragment闪烁

问题描述

我从BottomSheetDialogFragment开始活动。

但是当我完成活动时,BottomSheetDialogFragment闪烁了。

我的案子就是这样的BottomSheetDialog background blinking

但是没有解决办法。

Here is my screen shot

代码简单而基本。

MainActivity.class

role = message.guild.roles.cache.find((r) => r.name === AssignedFactions[i]); //AssignedFactions is an array containing a list of roles,by the name of the role. I is a number,1-7,representing which player in the loop is currently being assigned. Loop will add +1 to i every time it assigns a player,and the loop will terminate when i > 7 or i > the player count.
let member = message.guild.members.cache.get(Assignedplayers[i]); //Assignedplayers is an array containing a list of the players in the game,by username
console.log(Assignedplayers[i]);
console.log(AssignedFactions[i]);
console.log(member);
console.log(role);
member.roles.add(role).catch(console.error);

// member always returns undefined

BottomSheetFragment.class

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val bottomSheetFragment = BottomSheetFragment()

        button.setonClickListener {

            bottomSheetFragment.show(supportFragmentManager,"")
        }
    }
}

解决方法

您的底部工作表没有闪烁。回到MainActivity时,它对活动的影响。 在您的MainActivity中,请在onCreate()之前实现overridePendingTransition

overridePendingTransition(0,0) //由于此默认效果将被删除