-
Notifications
You must be signed in to change notification settings - Fork 118
Adding a custom view
Javier Santos edited this page Nov 1, 2017
·
3 revisions
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/custom_text_view"
android:text="This is a simple demonstration on how to add custom views to a BottomDialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/custom_button"
android:text="click to dismiss dialog"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
### 2. Inflate the layout in your activity
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View customView = inflater.inflate(R.layout.custom_view, null);
TextView customText = (TextView) customView.findViewById(R.id.custom_text_view);
Button dismissButton = (Button) customView.findViewById(R.id.custom_button);
...
new BottomDialog.Builder(this)
.setTitle("Awesome!")
.setContent("What can we improve? Your feedback is always welcome.")
.setCustomView(customView)
// You can also show the custom view with some padding in DP (left, top, right, bottom)
//.setCustomView(customView, 20, 20, 20, 0)
.show();
- You can customize the dialog with other library customizations.