標籤:android style http io color ar os 使用 sp
1、將MainActivity以對話方塊的形式顯示,首先在AndroidManifest.xml 檔案中,申明 activity 的主題使用自訂對話方塊樣式。
<activity
android:name=".MainActivity"
android:label="@string/activity_custom_dialog"
android:theme
=
"@style/Theme.CustomDialog"
>
<
intent-filter
>
<
action
android:name
=
"android.intent.action.MAIN"
/>
<
category
android:name
=
"android.intent.category.SAMPLE_CODE"
/>
</
intent-filter
>
</
activity
>
2、res/values/styles.xml 樣式檔案中定義一個對話方塊主題樣式,這裡繼承了 android:style/Theme.Dialog 主題,
並且視窗樣式 android:windowBackground 引用了 @drawable/filled_box
<
style
name
=
"Theme.CustomDialog"
parent
=
"android:style/Theme.Dialog"
>
<
item
name
=
"android:windowBackground"
>@drawable/filled_box</
item
>
</
style
>
3、res/drawable/filled_box.xml 定義了 Shape 類型的 drawable(抽象的可畫地區),最終是通過這個來實現新對話方塊的樣式。
<
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
>
Android 將Activity以對話方塊(Dialog)形式顯示