I have written code for bottom pop in fragment view.
.JAVA
languages_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
BottomSheetFragment bottomSheetFragment = new BottomSheetFragment();
Bundle args = new Bundle();
args.putString("key", "2");
bottomSheetFragment.setArguments(args);
bottomSheetFragment.show(getParentFragmentManager(), bottomSheetFragment.getTag());
}
});
.XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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="wrap_content"
android:layout_gravity="bottom"
android:background="@android:color/white"
tools:context=".BottomSheetFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:padding="20dp"
android:layout_width="150dp"
android:layout_height="6dp"
android:layout_gravity="center"
android:background="@color/cardview_shadow_start_color" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/viewData"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:gravity="center"/>
<Button
android:id="@+id/btnClosePopup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Close"
android:layout_gravity="end"/>
</LinearLayout>
<RadioGroup
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="15dp">
<RadioButton
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="English"/>
<RadioButton
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="English"/>
<RadioButton
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="English"/>
</RadioGroup>
</LinearLayout>
</LinearLayout>
for this I am getting output like this: enter image description here enter image description here
but, when i do this code in activity
btnShowPopup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
BottomSheetFragment bottomSheetFragment = new BottomSheetFragment();
Bundle args = new Bundle();
args.putString("key", "2");
bottomSheetFragment.setArguments(args);
bottomSheetFragment.show(getSupportFragmentManager(), bottomSheetFragment.getTag());
}
});
enter image description here enter image description here
here I want to output as same as activity, when we click the btnShowPopup btn then we can see the background of that activity
i need same when we click on languages_btn btn then we need to able to see fragment in background.
I use only Java XML Android Studio