Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> 文字選中顯示圖標android textSelectHandleRight

文字選中顯示圖標android textSelectHandleRight

編輯:關於Android編程

幾天要做文本選中處理,用到了textSelectHandleRight屬性

這幾個屬性的效果textSelectHandleRight textSelectHandleLeft textSelectHandle簡單點說可以看系統文本選中時出現的復制箭頭,左邊,右邊的,就是用的這個效果

 

查看android源碼可以發現定義方式在styles.xml裡


 <style name="Widget.TextView">
        <item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
        <item name="android:textSelectHandleLeft">?android:attr/textSelectHandleLeft</item>
        <item name="android:textSelectHandleRight">?android:attr/textSelectHandleRight</item>
        <item name="android:textSelectHandle">?android:attr/textSelectHandle</item>
        <item name="android:textEditPasteWindowLayout">?android:attr/textEditPasteWindowLayout</item>
        <item name="android:textEditNoPasteWindowLayout">?android:attr/textEditNoPasteWindowLayout</item>
        <item name="android:textEditSidePasteWindowLayout">?android:attr/textEditSidePasteWindowLayout</item>
        <item name="android:textEditSideNoPasteWindowLayout">?android:attr/textEditSideNoPasteWindowLayout</item>
        <item name="android:textEditSuggestionItemLayout">?android:attr/textEditSuggestionItemLayout</item>
        <item name="android:textCursorDrawable">?android:attr/textCursorDrawable</item>
    </style>
在attr.xml裡


 <!-- Reference to a drawable that will be used to display a text selection
             anchor on the left side of a selection region. -->
        <attr name="textSelectHandleLeft" />
        <!-- Reference to a drawable that will be used to display a text selection
             anchor on the right side of a selection region. -->
        <attr name="textSelectHandleRight" />
        <!-- Reference to a drawable that will be used to display a text selection
             anchor for positioning the cursor within text. -->
        <attr name="textSelectHandle" />
在theme.xml text部分


  <!-- Text selection handle attributes -->
        <item name="textSelectHandleLeft">@android :drawable/text_select_handle_left</item>
        <item name="textSelectHandleRight">@android :drawable/text_select_handle_right</item>
        <item name="textSelectHandle">@android :drawable/text_select_handle_middle</item>
        <item name="textSelectHandleWindowStyle">@android :style/Widget.Holo.TextSelectHandle</item>
        <item name="textSuggestionsWindowStyle">@android :style/Widget.Holo.TextSuggestionsPopupWindow</item>
        <item name="textCursorDrawable">@android :drawable/text_cursor_holo_dark</item>

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved