[Android Samples视频系列之ApiDemos] App-Activity-Translucent

[b]1.Demo说明与演示[/b]
该Demo显示一个半透明Activity,主要是通过Style和Theme来实现的
效果图如下:

[img]http://dl.iteye.com/upload/attachment/0077/4567/19a0f50c-e9a5-31ef-8a00-49995819fd8b.png[/img]

[b]2.视频讲解[/b]

[url]http://www.eyeandroid.com/thread-10936-1-1.html[/url]
[b]3.Demo分析[/b]
Activity分类示例的最后几个例子是来显示半透明Activity。例子大同小异。实现Activity的半透明效果主要是通过Style和Theme来实现的。
看看TranslucentActivity 在AndroidManifest.xml中的定义:
<activity android:name=”.app.TranslucentActivity”
android:label=”@string/activity_translucent”
android:theme=”@style/Theme.Translucent”>
<intent-filter>
< action android:name=”android.intent.action.MAIN” />
<category android:name=”android.intent.category.SAMPLE_CODE” />
< /intent-filter>
< /activity>
它使用了Theme.Translucent 主题,这个主题定义在res/styles.xml
<!– A theme that has a translucent background. Here we explicitly specify
that this theme is to inherit from the system’s translucent theme,
which sets up various attributes correctly. –>
<style name=”Theme.Translucent” parent=”android:style/Theme.Translucent”>
<item name=”android:windowBackground”>@drawable/translucent_background</item>
< item name=”android:windowNoTitle”>true</item>
< item name=”android:colorForeground”>#fff</item>
< /style>
它通过继承系统主题android:style/Theme.Translucent,然后加以修改。@drawable/translucent_background定义在Colors.xml中,颜色值为#e0000000 ,alpha值,也就是透明度为#e0(半透明)。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值