Dialog
/**
* 登陆dialog
*/
private void loginDialog(final Course course) {
loginDialog = new Dialog(this, R.style.Login_dialog);
loginDialog.setContentView(R.layout.login_dialog);
loginDialog.show();
final EditText username = (EditText) loginDialog.getWindow()
.findViewById(R.id.login_username);
}
style样式
<style name="Login_dialog" parent="@android:Theme.DeviceDefault.Light.Dialog">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
</style>
FragmentDialog
布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/modify_password_dialog_width"
android:layout_height="@dimen/modify_password_dialog_height"
android:background="@drawable/modify_pwd_background"
android:gravity="center"
android:orientation="vertical"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingTop="10dp" >
.........
</LinearLayout>
代码
public class SynchronyFragment extends DialogFragment {
public SynchronyFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
View view = inflater.inflate(R.layout.synchrony_fragment, container);
getDialog().getWindow().setBackgroundDrawable(
new ColorDrawable(Color.TRANSPARENT));
return view;
}
@Override
public void onDestroy() {
super.onDestroy();
}
}