圖標改變顏色:Drawable的變色,讓Android也能有iOS那么方便的圖片色調轉換,就像同一個圖標,但是有多個地方使用,并且顏色不一樣,就可以用這個方法了。
搜索框: 一般是EditText實現,本文 實現 TextView圖片和文字居中,鍵盤搜索。
來看看效果圖:
圖標改變顏色:第一個界面的左邊(二維碼)和右邊(更多)兩個實現,我放進去的圖片是黑色的,顯示出來是白色的。
搜索框:第一個界面的圖片和文字居中,還可以設置間距,第二個見面搜索設置鍵盤搜索按鈕,點擊搜索監聽事件,清除內容的圖標。
搜索框布局:
<!-- 搜索圖標設置 左邊 android:drawableLeft="@mipmap/icon_search" android:drawablePadding="5dp" 圖標和文字的間距 右邊 android:drawableRight="@mipmap/round_close" android:paddingRight="8dp" android:imeOptions="actionSearch" 設置成搜索按鈕 --> <EditText android:id="@+id/search_text" android:layout_width="0dp" android:layout_weight="1" android:layout_height="30dp" android:hint="輸入要搜索的商品" android:background="@drawable/search_gray" android:layout_marginTop="10dp" android:layout_marginLeft="9dp" android:textSize="12sp" android:drawableLeft="@mipmap/icon_search" android:paddingLeft="9dp" android:drawablePadding="5dp" android:drawableRight="@mipmap/round_close" android:paddingRight="8dp" android:imeOptions="actionSearch" android:maxLines="1" android:singleLine="true" />
本文題目:Android改變圖標原有顏色和搜索框的實例代碼-創新互聯
文章URL:http://m.2m8n56k.cn/article10/gjpgo.html
成都網站建設公司_創新互聯,為您提供Google、網站內鏈、網站維護、域名注冊、云服務器、外貿建站
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:[email protected]。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯