示例图如下;
android中自定义的一个可以弹出类似于提示更新的对话框_第1张图片

public class MainActivity extends Activity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        MyDialog dialog = new MyDialog(this);        dialog.show();    }}
public class MyDialog extends Dialog {    public MyDialog(Context context) {        super(context, R.style.Dialog);    }    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.dialog);        findViewById(R.id.rl).setOnTouchListener(new OnTouchListener() {            @Override            public boolean onTouch(View v, MotionEvent event) {                dismiss();                return false;            }        });        findViewById(R.id.ll).setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View v) {            }        });    }}

activity_main.xml

"http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:paddingBottom="@dimen/activity_vertical_margin"    android:paddingLeft="@dimen/activity_horizontal_margin"    android:paddingRight="@dimen/activity_horizontal_margin"    android:paddingTop="@dimen/activity_vertical_margin"    tools:context="com.example.lesson8_work.MainActivity" >    "wrap_content"        android:layout_height="wrap_content"        android:text="@string/hello_world" /></RelativeLayout>

dialog.xml

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:id="@+id/rl"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:background="#80000000"    android:orientation="vertical" >    <LinearLayout        android:id="@+id/ll"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_centerInParent="true"        android:background="@drawable/dialog_bg"        android:orientation="vertical"        android:padding="100dp" >        <TextView            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:background="@drawable/top"            android:gravity="center"            android:padding="10dp"            android:text="提示" />        <TextView            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:background="@android:color/white"            android:gravity="center"            android:padding="20dp"            android:text="更新" />        <View            android:layout_width="match_parent"            android:layout_height="1px"            android:background="@android:color/darker_gray" />        <LinearLayout            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:background="@drawable/bottom"            android:orientation="horizontal" >            <TextView                android:layout_width="0dp"                android:layout_height="wrap_content"                android:layout_weight="1"                android:gravity="center"                android:padding="10dp"                android:text="取消" />            <View                android:layout_width="1px"                android:layout_height="match_parent"                android:background="@android:color/darker_gray" />            <TextView                android:layout_width="0dp"                android:layout_height="wrap_content"                android:layout_weight="1"                android:gravity="center"                android:padding="10dp"                android:text="确定" />        LinearLayout>    LinearLayout>

values的styles中自己设置的Dialog样式

<resources>    <style name="AppBaseTheme" parent="android:Theme.Light">style>    <style name="AppTheme" parent="AppBaseTheme">style>    <style name="Dialog">        <item name="android:windowNoTitle">trueitem>        <item name="android:windowIsFloating">falseitem>        <item name="android:windowBackground">@android:color/transparent    style>resources>

drawable中自己画的一些图形

自己画的text的下半部分的样式bottom.xml

<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" >    <corners        android:bottomLeftRadius="10dp"        android:bottomRightRadius="10dp" />    <solid android:color="@android:color/white" />shape>

自己换的dialog背景dialog_bg.xml

<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" >    <corners android:radius="10dp" />shape>

自己换的text的上部分的样式top.xml

<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" >    <corners        android:topLeftRadius="10dp"        android:topRightRadius="10dp" />    <solid android:color="@android:color/darker_gray" />shape>

更多相关文章

  1. android自定义dialog样式
  2. 8.0 Launcher3 背景透明
  3. Android样式设计
  4. Android如何使用selector设置RelativeLayout的背景
  5. Android按钮样式(dmytrodanylyk)使用
  6. Android 透明背景的dialog
  7. android背景与style的设置

随机推荐

  1. Android(安卓)关机(reboot)流程
  2. android中ImageView、ImageButton、Butto
  3. android.util.Log常用的方法
  4. 在Android的Notification中显示进度条
  5. JS判断浏览器打开终端
  6. Android(安卓)IPC 机制【2】--- Messenge
  7. Android(安卓)获取当前语言的方法1
  8. android常用网址
  9. android 多张图片动画方式轮播(转载)
  10. androidannotations gradle Android(安卓