Last active
August 29, 2015 14:16
-
-
Save monmonja/a963c23b5c20cd76e9b9 to your computer and use it in GitHub Desktop.
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"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:orientation="vertical" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:paddingLeft="20dp" | |
android:paddingRight="20dp" | |
> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="vertical" | |
android:background="@drawable/dialog_fragment_bg" | |
> | |
<TextView | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:padding="10dp" | |
android:background="@android:color/holo_blue_bright" | |
android:text="Hello World" | |
/> | |
<TextView | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:padding="10dp" | |
android:text="Hello World" | |
/> | |
<Button | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_gravity="center_horizontal" | |
android:text="@android:string/ok"/> | |
</LinearLayout> | |
</LinearLayout> |
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"?> | |
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | |
<item> | |
<shape android:shape="rectangle"> | |
<solid android:color="#55000000"/> | |
<padding | |
android:bottom="3px" | |
android:left="3px" | |
android:right="3px" | |
android:top="3px" | |
/> | |
</shape> | |
</item> | |
<item> | |
<shape android:shape="rectangle" > | |
<solid android:color="@android:color/white"/> | |
</shape> | |
</item> | |
</layer-list> |
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
<resources> | |
<style name="DialogFragment" parent="android:style/Theme.Dialog"> | |
<item name="android:windowBackground">@android:color/transparent</item> | |
<item name="android:windowNoTitle">true</item> | |
<item name="android:windowIsFloating">true</item> | |
<item name="android:layout_gravity">center</item> | |
</style> | |
</resources> |
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
package com.monmonja.tutorial; | |
import android.app.Dialog; | |
import android.os.Bundle; | |
import android.support.annotation.NonNull; | |
import android.support.annotation.Nullable; | |
import android.support.v4.app.DialogFragment; | |
import android.view.View; | |
import android.view.ViewGroup; | |
public class TestDialogFragment extends DialogFragment { | |
@NonNull | |
@Override | |
public Dialog onCreateDialog(Bundle savedInstanceState) { | |
final View view = View.inflate(getActivity(), R.layout.dialog_fragment, null); | |
Dialog dialog = new Dialog(getActivity(), R.style.DialogFragment); | |
dialog.setContentView(view); | |
return dialog; | |
} | |
@Override | |
public void onStart() { | |
super.onStart(); | |
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); | |
} | |
@Override | |
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | |
super.onViewCreated(view, savedInstanceState); | |
// add view code | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment