当前位置:操作系统 > 安卓/Android >>

文字选中显示图标android textSelectHandleRight

几天要做文本选中处理,用到了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>

补充:移动开发 , Android ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,