啥都不說瓦侮,先上圖准给,
首先是布局文件dialog_layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
? ? android:layout_width="match_parent"
? ? android:layout_height="wrap_content"
? ? android:layout_centerInParent="true"
? ? android:background="@android:color/transparent">
? ? ? ? android:layout_width="match_parent"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_alignParentRight="true"
? ? ? ? android:layout_centerInParent="true"
? ? ? ? android:layout_centerVertical="true"
? ? ? ? android:layout_marginTop="@dimen/dimens_20"
? ? ? ? android:layout_marginRight="@dimen/dimens_10"
? ? ? ? android:layout_marginLeft="@dimen/dimens_10"
? ? ? ? android:background="@drawable/bg_border_dialog"
? ? ? ? android:minWidth="260dp"
? ? ? ? android:orientation="vertical">
? ? ? ? ? ? android:layout_width="150dp"
? ? ? ? ? ? android:layout_height="150dp"
? ? ? ? ? ? android:layout_gravity="center"
? ? ? ? ? ? android:layout_marginTop="@dimen/dimens_10"
? ? ? ? ? ? android:src="@mipmap/update_icon" />
? ? ? ? ? ? android:layout_width="match_parent"
? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? android:layout_marginTop="@dimen/dimens_10"
? ? ? ? ? ? android:gravity="center"
? ? ? ? ? ? android:text="發(fā)現(xiàn)有新版本"
? ? ? ? ? ? android:textColor="@color/text_content"
? ? ? ? ? ? android:textSize="@dimen/textSize_16"
? ? ? ? ? ? android:textStyle="bold" />
? ? ? ? ? ? android:layout_width="match_parent"
? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? android:layout_marginLeft="@dimen/dimens_20"
? ? ? ? ? ? android:layout_marginTop="@dimen/dimens_10"
? ? ? ? ? ? android:layout_marginRight="@dimen/dimens_20"
? ? ? ? ? ? android:layout_marginBottom="@dimen/dimens_10"
? ? ? ? ? ? android:gravity="center"
? ? ? ? ? ? android:text="第二個版本,修復了若干bug. "
? ? ? ? ? ? android:textSize="@dimen/textSize_14"
? ? ? ? ? ? android:textStyle="bold" />
? ? ? ? ? ? android:id="@+id/uptate_tv_version"
? ? ? ? ? ? android:layout_width="match_parent"
? ? ? ? ? ? android:layout_height="@dimen/dimens_40"
? ? ? ? ? ? android:layout_marginLeft="@dimen/dimens_20"
? ? ? ? ? ? android:layout_marginRight="@dimen/dimens_20"
? ? ? ? ? ? android:layout_marginBottom="@dimen/dimens_20"
? ? ? ? ? ? android:background="@drawable/ripple_press13"
? ? ? ? ? ? android:gravity="center"
? ? ? ? ? ? android:text="立即更新"
? ? ? ? ? ? android:textColor="@color/white" />
? ? ? ? android:id="@+id/dialogseven_delete"
? ? ? ? android:layout_width="30dp"
? ? ? ? android:layout_height="30dp"
? ? ? ? android:layout_alignParentRight="true"
? ? ? ? android:background="@mipmap/update_delete"
? ? ? ? android:visibility="visible"/>
</RelativeLayout>
------------------------------------------------------------------------------
其次是顯示dialog方法:------------------------------------
private void initUpdateDialog() {
picChooseDialog =new Dialog(AboutUsActivity.this, R.style.CustomDialog);
? ? View view = LayoutInflater.from(AboutUsActivity.this).inflate(
R.layout.test, null);
? ? final TextView uptate_tv_version = view.findViewById(R.id.uptate_tv_version);
? ? uptate_tv_version.setOnClickListener(new View.OnClickListener() {
@Override
? ? ? ? public void onClick(View v) {
}
});
? ? Window window =picChooseDialog.getWindow();
? ? window.setContentView(view);
? ? window.setGravity(Gravity.CENTER);
? ? window.setLayout(WindowManager.LayoutParams.WRAP_CONTENT,
? ? ? ? ? ? android.view.WindowManager.LayoutParams.WRAP_CONTENT);
? ? window.setWindowAnimations(R.style.popupWindowAnimation);
? ? picChooseDialog.setCanceledOnTouchOutside(true);
? ? picChooseDialog.show();
}
style樣式也貼出來吧:---------------------------------------
<style name="CustomDialog" parent="android:style/Theme.Dialog">
? ? <item name="android:windowBackground">@android:color/transparent
? ? <item name="android:windowNoTitle">true
? ? <item name="android:windowFrame">@null
? ? <item name="android:windowIsFloating">true
? ? <item name="android:backgroundDimEnabled">true
好了悉默,這是所有的更新版本的對話框哮缺。