[Android Samples視頻系列之ApiDemos] App-Activity-Translucent

來源:互聯網
上載者:User

1.Demo說明與示範

該Demo顯示一個半透明Activity,主要是通過Style和Theme來實現的

如下:


2.視頻講解

http://www.eyeandroid.com/thread-10936-1-1.html
3.Demo分析

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(半透明)。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.