Created
February 15, 2020 12:58
-
-
Save yunusemredilber/1de4c88e896c81f87d0ea5a126b81dae to your computer and use it in GitHub Desktop.
Android - Material Modal Bottom Sheets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<androidx.constraintlayout.widget.ConstraintLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:background="@color/colorPrimary" | |
android:id="@+id/my_modal_bottom_sheet_view"> | |
<LinearLayout | |
app:layout_constraintTop_toTopOf="parent" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintLeft_toLeftOf="parent" | |
app:layout_constraintRight_toRightOf="parent" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:gravity="center" | |
android:layout_gravity="center" | |
android:minHeight="150dp" | |
android:padding="15dp" | |
android:orientation="vertical"> | |
<!-- Your Content --> | |
</LinearLayout> | |
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.os.Bundle; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import com.google.android.material.bottomsheet.BottomSheetDialogFragment; | |
public class LocationPermissionBottomSheet extends BottomSheetDialogFragment { | |
@Override | |
public View onCreateView (LayoutInflater inflater, | |
ViewGroup container, | |
Bundle savedInstanceState) { | |
return inflater.inflate(R.layout.my_modal_bottom_sheet, container, false); | |
} | |
} | |
/* | |
* To show: | |
* MyModalBottomSheet myModalBottomSheet = new MyModalBottomSheet(); | |
* myModalBottomSheet.show(getSupportFragmentManager(), ""); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment