Change native android selection handles



  • Hi,

    as of Qt 5.8, it's now possible to select text with the native android selection handles. (see https://codereview.qt-project.org/#/c/142466/ ). Now I would like to exchange the default Android selection handles

    alt text alt text
    alt text

    with the material design selection handles. Therefore, I copied the material design selection handles to my drawablefolder and created a custom apptheme.xml with the following content:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <style name="AppTheme" parent="@android:style/Theme.Holo.Light.NoActionBar">
            <item name="android:textSelectHandle">@drawable/text_select_handle_middle</item>
            <item name="android:textSelectHandleLeft">@drawable/text_select_handle_left</item>
            <item name="android:textSelectHandleRight">@drawable/text_select_handle_right</item>
        </style>
    </resources>
    

    In my AndroidManifest.xml I reference the custom style with

    <application
            ...
            android:theme="@style/AppTheme">
            ...
    </application>
    

    However, the style of the selection handles doesn't change. Anybody an idea what I am doing wrong?



  • Just encountered a same issue myself and manage to stumble upon a solution after a long period of searching barely documented android docs. Anyways, for some reason, the theme is not read from the AndroidManifext.xml, not in this case anyways. So to solve it, you have to manually load your theme file in Activity's onCreate() method like so:

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTheme(R.style.AppTheme);
        // rest of the code ...
    }
    

Log in to reply