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>
  • 相关阅读:
    python解析网页中js动态添加的内容
    pycharm索引index时间很长的原因
    github/gitlab ssh-keys全局唯一
    使用gc、objgraph干掉python内存泄露与循环引用!
    ImportError: No module named _curses;Color support is disabled, python-curses is not installed.解决办法
    jinjia2模板学习
    flask可以通过缓存模板或者页面达到性能提升
    python的websocket实现Tornado
    flask的debug模式下,网页输入pin码进行调试
    Git 环境安装
  • 原文地址:https://www.cnblogs.com/dyllove98/p/3177731.html
Copyright © 2011-2022 走看看