zoukankan      html  css  js  c++  java
  • Api demo源码学习(2)App/Activity/Custom Dialog 自定义Activity样式

    这一节比较简单,让Activity以自定义的Dialog形式展现出来,只需要配置一系列的xml文档即可。一直没有做过比较大型的项目,翻看apidemo的xml文档才知道配置工作也有很大的工作量。xml中的许多标签之前都没有接触过。

    Activity不需要做任何修改。

    首先配置AndroidManifest.xml文档,添加一条属性,指定该antivity以指定的style显示:
    android:theme="@style/Theme.CustomDialog"

    然后在res/values 目录下建立styles.xml文件,建立一个style样式,该style样式继承于android自带的Theme.Dialog样式
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
           <style name="Theme.CustomDialog" parent="android:style/Theme.Dialog">
            <item name="android:windowBackground">@drawable/filled_box</item>
           </style>
    </resources

    在res/drawable 目录下建立filled_box.xml文件,定义一个shape,用来规定activity的外框样式
    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
        <solid android:color="#f0600000"/>
        <stroke android:width="3dp" color="#ffff8080"/>
        <corners android:radius="3dp" />
        <padding android:left="10dp" android:top="10dp"
            android:right="10dp" android:bottom="10dp" />
    </shape>

    最后修改res/layout目录下的main.xml文件,规定textview的显示格式
    <?xml version="1.0" encoding="utf-8"?>
    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
           android:id="@+id/text"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="center"
        android:text="show Custom Dialog"/>
     
    通过以上配置,就可以完成activity以指定的样式呈现。

  • 相关阅读:
    使用homebrew安装mysql
    MacOS下命令行安装神器brew
    mac Navicat 破解+汉化(亲测可用)
    eos开发(三)使用cleos命令行客户端操作EOS——关于钱包wallet和账户account
    eos开发(二)使用cleos命令行客户端操作EOS(钱包wallet基础操作)
    php职业规划
    temp
    事业随想
    系统时间错误
    加解密,token
  • 原文地址:https://www.cnblogs.com/xutao1988/p/2286809.html
Copyright © 2011-2022 走看看