Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrupted window size with Window.softinput_mode = 'below_target' #635

Closed
doug-letough opened this issue Feb 11, 2016 · 9 comments
Closed

Comments

@doug-letough
Copy link

On Android platform, if Window.softinput_mode is set to 'below_target', the window size is corrupted (Window content is shifted to top of 20 or 30 lines depending on device model).
This occurs even if the keyboard is not used.
This issue not occurs with others softinput_mode.
This issue seems related with issue #544.
This code runs nice on Linux platform and was not tested on Windows, OS X or iOS.
The same buggy behavior is encountered with both Kivy 1.9.0 and Kivy 1.9.1.
This code was tested on 2 different devices with Android 6.0 Marshmallow (HTC m8 and Nexus 7).
The tool chain used was buildozer 0.31 with the following parameters:

android.api = 14
android.minapi = 8
android.sdk = 21
android.ndk = 10e
#!/usr/bin/env python
# -*- coding: utf-8

from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.app import App
from kivy.core.window import Window

class MyClass(BoxLayout):

    def __init__(self, **kwargs):
        super(MyClass, self).__init__(**kwargs)
        softinput_mode = 'below_target'
        Window.softinput_mode = softinput_mode

class MyApp(App):
    def build(self):
        text = """
        Lorem ipsum dolor sit amet, consectetur adipiscing elit,
        sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
        Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
        aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit
        in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
        Excepteur sint occaecat cupidatat non proident, sunt in culpa qui
        officia deserunt mollit anim id est laborum"""
        setattr(self, 'text', text)

        return MyClass()

if __name__ == '__main__':
    my_app = MyApp()
    my_app.run()
#:kivy 1.9.1
<MyClass>:
    BoxLayout:
        id: main_layout
        orientation: 'vertical'
        canvas:
            Color:
                rgb: .5, .5, .5
            Rectangle:
                size: self.size
                pos: self.pos
        GridLayout:
            size_hint: (1, None)
            height: 200
            padding: 10
            rows: 1
            BoxLayout:
                canvas:
                    Color:
                        rgb: .2, .1, .5
                    Rectangle:
                        size: self.size
                        pos: self.pos
        Label:
            size_hint: (1,.1)
            text: app.text
            text_size: self.width - 20, self.height
            size: self.texture_size
            valign: 'top'
@doug-letough
Copy link
Author

I also noticed that if 2 TextInput widgets are on the same window, passing from a TextInput to another without touching whereever there is no focus capable widget will not release the keyboard so the newly focused TextInput will not be placed above the keyboard.

@doug-letough
Copy link
Author

Bug does not occur with the actual github Kivy version (1.9.2-dev0) and old toolchain (buildozer 0.31).

@akshayaurora
Copy link
Member

Yup, this was fixed in -dev use kivy==master to workaround the issue till a
new stable is released.

On Fri, Feb 12, 2016 at 2:15 PM, Doug Le Tough notifications@github.com
wrote:

Bug does not occurs with the actual github Kivy version (1.9.2-dev0) and
old toolchain (buildozer 0.31).


Reply to this email directly or view it on GitHub
#635 (comment)
.

@doug-letough
Copy link
Author

Finally there is still a problem even with kivy==master:
Replace the Kv code by the following one.

You'll see that top lines of window are still missing until focus is given to one of the TextInputs.
Passing from the top TextInput to the lower one (which has to be partially covered by the virtual keyboard, adjust size_hints to suit your configuration) does not release the keyboard so the lower TextInput is still covered by the keyboard (Tested on Android only).

<MyClass>:
    BoxLayout:
        id: main_layout
        orientation: 'vertical'
        padding: 10
        canvas:
            Color:
                rgb: .5, .5, .5
            Rectangle:
                size: self.size
                pos: self.pos
        GridLayout:
            size_hint: (1, .15)
            padding: 10
            rows: 1
            BoxLayout:
                canvas.before:
                    Color:
                        rgb: .2, .1, .5
                    Rectangle:
                        size: self.size
                        pos: self.pos
                Label:
                    size_hint: (1, 1)
                    color: 1, 1 ,1 ,1
                    text: "Lorem Ipsum"
                    size: self.texture_size
        TextInput:
            size_hint: (1, .25)
            text: app.text
        Label:
            size_hint: (1, .05)
        TextInput:
            size_hint: (1, .25)
            text: app.text
        Label:
            size_hint: (1, .3)

@inclement
Copy link
Member

I'm closing this since it's fixed in kivy master. Could you open an issue for the other one against kivy itself, as probably it needs to be fixed there (not in p4a).

@doug-letough
Copy link
Author

After further test, the bad window size bug described above is still present with latest kivy git version (kivy==master).
Run the python code with the last .kv and you'll see.

@akshayaurora
Copy link
Member

@doug-letough open a issue in kivy for this.

@dessant
Copy link
Contributor

dessant commented Mar 18, 2016

Let's port it.

@dessant
Copy link
Contributor

dessant commented Mar 18, 2016

This issue was moved to kivy/kivy#4098

@dessant dessant closed this as completed Mar 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants