BottomSheetDialog background blinking


BottomSheetDialog background blinking



BottomSheetDialog's background is blinking when switching between apps. What am I doing wrong ?


BottomSheetDialog



MainActivity.java


public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

findViewById(R.id.btn1).setOnClickListener(v -> {
BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(MainActivity.this);
bottomSheetDialog.setContentView(R.layout.content);
bottomSheetDialog.show();
});
}
}



activity_main.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=".MainActivity">

<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>



content.xml


<?xml version="1.0" encoding="utf-8"?>
<View 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="300dp"
android:background="#F00" />



AndroidManifest.xml


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.holtaf.testandroidapplication">

<application
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>



My appcompat version is 27.1.1.


appcompat



enter image description here



The question is widely applicable to a large audience. A detailed canonical answer is required to address all the concerns.





Can you post your complete code of the activity and its xml
– RoyalGriffin
Jun 29 at 9:28





OnResume your bottom sheet is getting refreshed. You might want to check that.
– mark922
Jun 29 at 9:30





@RoyalGriffin I have included my activity_main.xml also. This is the whole code I'm using right now.
– holtaf
Jun 29 at 9:52





I will investigate more, but my first impression is BottomSheetDialog class redraw the layout while pausing and starting. Time which is taken while pausing and starting it because of animation which BottomSheetDialog is having.
– jitesh mohite
17 hours ago









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Opening a url is failing in Swift

Export result set on Dbeaver to CSV