`

可关闭对话框

 
阅读更多

第二种:Activity的 onCreate 方法里 setTheme ,但是没有如我所愿的显示我要的效果)

那好吧,自定义风格

项目的 res / value 目录下 建立xml文件:mytheme.xml 内容如下

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="mytheme" parent="android:Theme.Dialog">
   <item name="android:windowNoTitle">true</item>
   <item name="android:textSize">20sp</item>
   <item name="android:textColor">#000000</item>
</style>[url][/url]
</resources>

注:
parent 属性用来继承,
我们这个 主题 就 继承自 android提供的 Dialog主题

然后在这个基础上 实现 android:windowNoTitle
也就是 不显示标题栏,
加上字体大小,字体颜色……

就是这样

在你的 AndroidManifest.xml 里使用你创建的主题吧
 
   <activity android:name=".MainActivity"
      android:theme="@style/mytheme"/>
效果图:

 

和使用 android 自带的主题方法类似:
<activity android:name=".StartActivity" android:theme="@android:style/Theme.NoTitleBar" />

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics