zoukankan      html  css  js  c++  java
  • android创建自定义对话框

    创建如下自定义对话框:

    JAVA代码

    LayoutInflater li = LayoutInflater.from(TagActivity. this);  //NOTE
    final View TestView = li.inflate(R.layout.tag_dialog, null);
    dialog =  new Dialog(TagActivity. this, R.style.dialog);
    dialog.setContentView(TestView);
    dialog.setCancelable( true);
    dialog.show();

    R.layout.tag_dialog如下

    <?xml version= "1.0"  encoding= "utf-8" ?>
    <LinearLayout xmlns:android= "http://schemas.android.com/apk/res/android"  android:layout_width= "match_parent"  android:layout_height= "match_parent"  android:orientation= "vertical" >
       <LinearLayout android:layout_height= "wrap_content"  android:layout_width= "fill_parent" >
         <TextView android:id= "@+id/title"  android:layout_height= "wrap_content"  android:layout_width= "fill_parent"  android:gravity= "center"  android:textColor= "@color/white"  android:paddingTop= "15dp" ></TextView>
       </LinearLayout>
       <LinearLayout android:layout_width= "200dp"  android:layout_height= "200dp"  android:orientation= "vertical"  android:paddingLeft= "10dp"  android:paddingRight= "10dp"  android:paddingTop= "10dp" >
         <EditText android:id= "@+id/name"  android:layout_width= "fill_parent"  android:layout_height= "wrap_content"  android:background= "@color/transparent"  android:textColor= "@color/white"  android:hint= "输入消息内容"  android:textColorHint= "@color/white" ></EditText>
       </LinearLayout>
       <LinearLayout android:layout_width= "fill_parent"  android:layout_height= "wrap_content"  android:orientation= "horizontal"  android:layout_marginBottom= "10dp" >
         <RelativeLayout android:layout_width= "fill_parent"  android:layout_height= "wrap_content"  android:layout_weight= "1" >
           <ImageButton android:id= "@+id/sure"  android:layout_width= "wrap_content"  android:layout_height= "wrap_content"  android:src= "@drawable/sure"  android:background= "@drawable/btn_click_background"  android:layout_centerHorizontal= "true" ></ImageButton>
         </RelativeLayout>
         <RelativeLayout android:layout_width= "fill_parent"  android:layout_height= "wrap_content"  android:layout_weight= "1" >
           <ImageButton android:id= "@+id/cancel"  android:layout_width= "wrap_content"  android:layout_height= "wrap_content"  android:src= "@drawable/cancel"  android:background= "@drawable/btn_click_background"  android:layout_centerHorizontal= "true" ></ImageButton>
         </RelativeLayout>
       </LinearLayout>
    </LinearLayout>

    R.style.dialog文件如下

    <!-- 下面是对话框对应的style -->
    <style name= "dialog"  parent= "@android:style/Theme.Dialog" >
       <item name= "android:windowFrame" >@null </item>
       <item name= "android:windowIsFloating" >true </item>
       <item name= "android:windowIsTranslucent" >true </item>
       <item name= "android:windowNoTitle" >true </item>
       <!--<item name="android:background">@android:color/transparent</item>-->
       <item name= "android:background" >@android:color /transparent </item>
       <item name= "android:windowBackground" >@drawable /dialog_bg </item>
       <item name= "android:backgroundDimEnabled" >true </item>
       <item name= "android:backgroundDimAmount" >0.6 </item>
       <item name= "android:windowFullscreen" >true </item>
    </style>
  • 相关阅读:
    Dynamics CRM开发参考资料
    Sql Server存储过程和游标的配合操作
    C#字符处理的性能问题
    Windows安装完ADFS后卸载ADFS清除ADFS数据库
    C#修改AD账号及密码
    Dynamics CRM安装教程九(续):自建证书的CRM项目客户端设置CRM访问
    Kubernetes实践之深入掌握Pod——Pod健康检查和服务可用性检查
    Kuberbetes实践——镜像拉取策略、command args参数、Pod生命周期和重启策略
    Kubernetes实践之深入掌握Pod——在容器内获取Pod信息
    Kubernetes实践之深入掌握Pod——ConfigMap
  • 原文地址:https://www.cnblogs.com/dyllove98/p/3177731.html
Copyright © 2011-2022 走看看