久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Android 使用形狀、選擇器或列表的不同狀態的不同

Android different EditText backgrounds for different states using shapes, selector or list(Android 使用形狀、選擇器或列表的不同狀態的不同 EditText 背景)
本文介紹了Android 使用形狀、選擇器或列表的不同狀態的不同 EditText 背景的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在啟動一個使用 ActionBarSherlock & 的新應用程序.HoloEverywhereLib.我的最小&目標 SDK 相同(10/2.3.3).這只是為了讓我也可以快速將其移植到亞馬遜 Kindle &BB10 使用他們擁有的 android 運行時(已經將此設置用于另一個應用程序并且它可以正常工作).一直以來,應用程序的外觀應盡可能接近 ICS/JB.

I'm starting a new app where I use ActionBarSherlock & HoloEverywhereLib. My min & target SDK are the same (10/2.3.3). This is just so I can also quickly port it to Amazon Kindle & BB10 using the android runtime they have (already used this setup for another app and it worked without issue). All the while the app should have as close to ICS/JB look as possible.

不過,對于我的 EditTexts,我給他們一個 Girgerbread/iOS(圓角,但沒有陰影)的外觀

For my EditTexts though, I'm giving them a Girgerbread/iOS (round corners, but no shadows) look to them

幾周前有人向我提到要獲取 Gingerbread 的可繪制對象并將它們用于我的 EditTexts.但我開始使用我在 S/O 找到的另一個答案,非常簡單:

Someone mentioned to me a few weeks ago to grab the drawables for Gingerbread and use them to my EditTexts. but i starting using another answer I found here at S/O, very simple:

<EditText
 background:"@drawable/edittext_round_white"
 ..../>

&我的edittext_round_white.xml:

& my edittext_round_white.xml:

 <?xml version="1.0" encoding="utf-8"?>
 <shape xmlns:android="http://schemas.android.com/apk/res/android" 
  android:shape="rectangle"
  >
  <corners android:radius="8dp"/>
<stroke android:width="1dp"
    android:color="#444"/>
<solid android:color="#FFFFFF" />
  </shape>

現在,當我運行應用程序時,有兩件事不對

Now, when I run the app, two things are not right

a) 根本沒有焦點"(我知道我需要實現這一點,這是問題的重點)

a) there is no 'focus' at all (I'm aware I need to implement this, it's the point of the question)

b) 光標根本沒有出現在我的編輯文本中(灰色垂直線提示輸入在編輯文本中的位置)

b) the cursor does not appear at all in my edittext (the gray vertical line hinting at to where in the edittext the input is directed)

對于一個)我假設我必須使用某種選擇器或列表,對嗎?如何?我是 android 樣式的新手,任何幫助將不勝感激.我唯一要改變的是描邊顏色.

For a) I assume I've to use some sort of selector or list, right? how? I'm new to styling in android and any help would be appreciated. The only thing I'm going to change is the stroke color.

對于 b) 我怎樣才能讓光標出現?

For b) how can I make cursor show up?

非常歡迎任何提示/鏈接/等!

Any hints / links / etc here are very much welcomed!

推薦答案

我建議使用 NinePatch 圖片來自定義你的 EditText.這是基于我的代碼的示例:

I suggest to use NinePatch images to customize your EditText. Here goes an example based on my code:

選擇器:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_window_focused="false" android:state_enabled="true"
        android:drawable="@drawable/twitter_im_edittext_normal" />
  <item android:state_window_focused="false" android:state_enabled="false"
        android:drawable="@drawable/twitter_im_edittext_normal" />
  <item android:state_pressed="true" android:drawable="@drawable/twitter_im_edittext_normal" />
  <item android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/twitter_im_edittext_focused" />
  <item android:state_enabled="true" android:drawable="@drawable/twitter_im_edittext_normal" />
  <item android:state_focused="true" android:drawable="@drawable/twitter_im_edittext_focused" />
  <item android:drawable="@drawable/twitter_im_edittext_normal" />
</selector>

使用與代碼中相同的方式使用選擇器,將其設置為 EditText 的背景.

Use selector the same way you used in your code, set it to background of your EditText.

圖片:

twitter_im_edittext_focused.9.png

twitter_im_edittext_focused.9.png

twitter_im_edittext_normal.9.png

twitter_im_edittext_normal.9.png

您可以在這里找到更多關于 NinePatch 圖像的信息這里.

More about NinePatch images you can found here.

希望對你有幫助.

這篇關于Android 使用形狀、選擇器或列表的不同狀態的不同 EditText 背景的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

EditText: Disable Paste/Replace menu pop-up on Text Selection Handler click event(EditText:禁用文本選擇處理程序單擊事件上的粘貼/替換菜單彈出)
Multiline EditText with Done SoftInput Action Label on 2.3(2.3 上帶有完成 SoftInput 操作標簽的多行 EditText)
How to detect the swipe left or Right in Android?(如何在 Android 中檢測向左或向右滑動?)
Prevent dialog dismissal on screen rotation in Android(防止在Android中的屏幕旋轉對話框解除)
How do I handle ImeOptions#39; done button click?(如何處理 ImeOptions 的完成按鈕點擊?)
How do you set EditText to only accept numeric values in Android?(您如何將 EditText 設置為僅接受 Android 中的數值?)
主站蜘蛛池模板: 欧美福利 | 91免费看片神器 | 久久久国产一区二区三区 | 91久久久久久| 久久国产精品一区二区三区 | 国外成人在线视频 | 真人女人一级毛片免费播放 | aⅴ色国产 欧美 | 国产精品视频不卡 | 日韩在线免费观看视频 | 欧美男人天堂 | 天堂精品 | 精精国产xxxx视频在线 | 国产精品人人做人人爽 | 日本黄视频在线观看 | 狠狠躁18三区二区一区 | 九一视频在线播放 | 亚洲在线 | 国产高清久久 | 青青久久 | 日韩1区 | 午夜电影福利 | 美女一级毛片 | 超碰免费在 | 日韩欧美国产精品一区 | 亚洲精品二区 | 九九热最新视频 | 亚洲综合热 | 国产精品永久久久久 | 怡红院免费的全部视频 | 黑人精品欧美一区二区蜜桃 | www.精品国产 | 欧美日韩久久精品 | 日韩国产一区二区三区 | 狠狠操狠狠操 | 亚洲第一区国产精品 | 搞黄视频免费看 | 操夜夜| 久草久 | 中文字幕在线观看第一页 | 亚洲精品乱码久久久久久按摩观 |