• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            大龍的博客

            常用鏈接

            統計

            最新評論

            修改Button樣式 --- 轉

            Android SDK doc : http://androidappdocs.appspot.com/reference/android/widget/ImageButton.html

            Displays a button with an image (instead of text) that can be pressed or clicked by the user. By default, an ImageButton looks like a regular Button, with the standard button background that changes color during different button states. The image on the surface of the button is defined either by the android:src attribute in the<ImageButton> XML element or by the setImageResource(int) method.

            ImageButton中修改按鈕樣式需要定一個Xml元素表,并在Layout xml中用android:src加載效果。

            To remove the standard button background image, define your own background image or set the background color to be transparent.

            移除標準按鈕背景圖片,自定義背景圖片或者設置背景圖片的顏色為透明。

            To indicate the different button states (focused, selected, etc.), you can define a different image for each state. E.g., a blue image by default, an orange one for when focused, and a yellow one for when pressed. An easy way to do this is with an XML drawable "selector." For example:

            為了區分按鈕的不同狀態(聚焦,被選中等),你可以使用不同的圖片....

            1. <?xml version="1.0" encoding="utf-8"?>  
            2. <selector xmlns:android="http://schemas.android.com/apk/res/android">  
            3.     <item android:state_pressed="true"  
            4.           android:drawable="@drawable/button_pressed" /> <!-- pressed -->  
            5.     <item android:state_focused="true"  
            6.           android:drawable="@drawable/button_focused" /> <!-- focused -->  
            7.     <item android:drawable="@drawable/button_normal" /> <!-- default -->  
            8. </selector>  

            Save the XML file in your project res/drawable/ folder and then reference it as a drawable for the source of your ImageButton (in the android:src attribute). Android will automatically change the image based on the state of the button and the corresponding images defined in the XML.

            將該文件保存在 res/drawable/下 并使用android:src標簽引用。 Android會自動改變對應狀態的背景圖片。

            The order of the <item> elements is important because they are evaluated in order. This is why the "normal" button image comes last, because it will only be applied afterandroid:state_pressed and android:state_focused have both evaluated false.

            在<item>標簽列表的順序是至關重要的,因為只有在android:state_pressed和android:state_focuesd 同時為false的情況下,默認的圖標樣式才會被顯示(沒按放在那里的時候,看到的按鈕樣式)

            1. <?xml version="1.0" encoding="utf-8"?>  
            2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
            3.     android:orientation="vertical"  
            4.     android:layout_width="fill_parent"  
            5.     android:layout_height="fill_parent"  
            6.     android:background="#ffffffff"  
            7.     >  
            8. <Button    
            9.     android:id ="@+id/btn"  
            10.     android:layout_width="wrap_content"   
            11.     android:layout_height="wrap_content"   
            12.     android:text="Hello"  
            13.     android:textColor="#ffffffff"  
            14.     android:background="@drawable/newbtn"  
            15.     />  
            16. </LinearLayout>  

            posted on 2010-06-15 16:17 大龍 閱讀(1726) 評論(0)  編輯 收藏 引用

            久久精品国产亚洲AV不卡| 2021久久精品国产99国产精品| 99久久免费只有精品国产| 国产成人精品综合久久久| 久久久噜噜噜久久中文字幕色伊伊| 欧美日韩精品久久久久| 久久久久亚洲Av无码专| 国产伊人久久| 国内精品九九久久久精品| 亚洲精品国产自在久久| 成人久久精品一区二区三区| 欧美午夜精品久久久久久浪潮| 亚洲乱码精品久久久久..| 九九久久精品国产| 国产一级持黄大片99久久| 欧美精品九九99久久在观看| 国产日韩欧美久久| 久久精品成人国产午夜| 婷婷综合久久中文字幕蜜桃三电影| 久久www免费人成看国产片| 久久久久中文字幕| 奇米影视7777久久精品| 狠狠色丁香婷婷久久综合| 激情综合色综合久久综合| 91久久国产视频| 国产精品久久久久久久久久免费| 99精品久久精品| 久久久av波多野一区二区| 亚洲精品tv久久久久久久久| 伊人久久久AV老熟妇色| 精品综合久久久久久98| 2021久久精品免费观看| 精品国产乱码久久久久软件| 欧美一区二区久久精品| 日本五月天婷久久网站| 久久久www免费人成精品| 亚洲伊人久久综合影院| 日韩人妻无码一区二区三区久久99 | 少妇精品久久久一区二区三区| 7777精品伊人久久久大香线蕉| 色老头网站久久网|