日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

html 添加窗口小部件,如何:为自定义窗口小部件定义主题(样式)项

發(fā)布時間:2024/7/23 58 豆豆
生活随笔 收集整理的這篇文章主要介紹了 html 添加窗口小部件,如何:为自定义窗口小部件定义主题(样式)项 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

波斯汪

是的,有一種方法:假設您有一個小部件的屬性聲明(在中attrs.xml):? ? 聲明用于樣式參考的屬性(在中attrs.xml):? ? 為小部件聲明一組默認屬性值(在中styles.xml):聲明自定義主題(在中themes.xml):將此屬性用作窗口小部件的構造函數(shù)中的第三個參數(shù)(在中CustomImageButton.java):public class CustomImageButton extends ImageButton {? ? private String customAttr;? ? public CustomImageButton( Context context ) {? ? ? ? this( context, null );? ? }? ? public CustomImageButton( Context context, AttributeSet attrs ) {? ? ? ? this( context, attrs, R.attr.customImageButtonStyle );? ? }? ? public CustomImageButton( Context context, AttributeSet attrs,? ? ? ? ? ? int defStyle ) {? ? ? ? super( context, attrs, defStyle );? ? ? ? final TypedArray array = context.obtainStyledAttributes( attrs,? ? ? ? ? ? R.styleable.CustomImageButton, defStyle,? ? ? ? ? ? R.style.Widget_ImageButton_Custom ); // see below? ? ? ? this.customAttr =? ? ? ? ? ? array.getString( R.styleable.CustomImageButton_customAttr, "" );? ? ? ? array.recycle();? ? }}現(xiàn)在,您必須應用Theme.Custom到所有使用的活動CustomImageButton(在AndroidManifest.xml中):就這樣?,F(xiàn)在CustomImageButton嘗試從customImageButtonStyle當前主題的屬性加載默認屬性值。如果在主題或屬性的值中未找到此類屬性@null,obtainStyledAttributes則將使用的最后一個參數(shù):Widget.ImageButton.Custom在這種情況下。您可以更改所有實例和所有文件的名稱(除外AndroidManifest.xml),但是使用Android命名約定會更好。

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎

總結

以上是生活随笔為你收集整理的html 添加窗口小部件,如何:为自定义窗口小部件定义主题(样式)项的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。