Skip to content

Instantly share code, notes, and snippets.

@Lzyct
Created January 5, 2017 11:27
Show Gist options
  • Select an option

  • Save Lzyct/38d78fdc5f3c0515b7f152d17620ed80 to your computer and use it in GitHub Desktop.

Select an option

Save Lzyct/38d78fdc5f3c0515b7f152d17620ed80 to your computer and use it in GitHub Desktop.
Sample floating
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/ll_konten"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:background="@drawable/background"
android:gravity="center"
android:orientation="vertical"
android:padding="@dimen/activity_horizontal_margin">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ini contoh judul" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ini contoh konten" />
</LinearLayout>
<LinearLayout
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/ll_konten"
android:layout_centerHorizontal="true"
android:layout_marginBottom="45dp"
android:background="@drawable/background_rounded"
android:orientation="vertical"
android:padding="@dimen/activity_horizontal_margin">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="title"
android:textColor="#fff" />
</LinearLayout>
</RelativeLayout>
<style name="CustomDialog" parent="Theme.AppCompat.Dialog.Alert">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>
View dialogView = getLayoutInflater().inflate(R.layout.custom_dialog, null);
Dialog customDialog = new Dialog(this, R.style.CustomDialog);
customDialog.setContentView(dialogView);
customDialog.setCancelable(true);
customDialog.getWindow().setLayout(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
customDialog.show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment