• <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>

            大龍的博客

            常用鏈接

            統(tǒng)計(jì)

            最新評(píng)論

            修改Button樣式 --- 轉(zhuǎn)

            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中修改按鈕樣式需要定一個(gè)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.

            移除標(biāo)準(zhǔn)按鈕背景圖片,自定義背景圖片或者設(shè)置背景圖片的顏色為透明。

            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:

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

            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標(biāo)簽引用。 Android會(huì)自動(dòng)改變對(duì)應(yīng)狀態(tài)的背景圖片。

            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>標(biāo)簽列表的順序是至關(guān)重要的,因?yàn)橹挥性赼ndroid:state_pressed和android:state_focuesd 同時(shí)為false的情況下,默認(rèn)的圖標(biāo)樣式才會(huì)被顯示(沒按放在那里的時(shí)候,看到的按鈕樣式)

            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 大龍 閱讀(1723) 評(píng)論(0)  編輯 收藏 引用


            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            久久ww精品w免费人成| 麻豆av久久av盛宴av| 国产精品久久网| 91久久精品无码一区二区毛片| 91超碰碰碰碰久久久久久综合| 久久影视国产亚洲| 亚洲成色WWW久久网站| 国产精品青草久久久久婷婷| 久久精品国产第一区二区| 亚洲成av人片不卡无码久久| 亚洲va久久久噜噜噜久久| 久久精品九九亚洲精品天堂| 波多野结衣AV无码久久一区| 99久久无码一区人妻a黑| 久久e热在这里只有国产中文精品99 | 久久青青草视频| 婷婷久久久亚洲欧洲日产国码AV| 久久精品国产91久久综合麻豆自制| 国产亚洲成人久久| 久久综合狠狠综合久久| 99久久免费国产精品| 精品国产乱码久久久久软件| 狠狠色丁香婷综合久久| 国产精品久久新婚兰兰| 久久91综合国产91久久精品| 国产99久久久国产精品小说| 久久99国产亚洲高清观看首页| 国产69精品久久久久APP下载| 久久青青草原国产精品免费 | 国产免费久久精品丫丫| 99久久精品免费看国产一区二区三区 | 久久er国产精品免费观看8| 久久久久亚洲AV无码网站| 久久久久综合国产欧美一区二区| 狠狠色丁香久久婷婷综合五月 | 亚洲综合久久夜AV | 99久久亚洲综合精品网站| 久久久久免费看成人影片| 久久精品国产2020| 一本久久免费视频| 欧美色综合久久久久久|