How to move text upwards on the screen every time a button is pressed

前端 未结 2 1339
粉色の甜心
粉色の甜心 2021-01-16 10:32

I want to develop a chatting application for android. It will receive messages from the controller on the site. For this i have started designing a GUI. After practicing and

2条回答
  •  孤城傲影
    2021-01-16 10:46

    I tried to change the appearance a little bit. I wanted send, receive button and textinput at the bottom and label on top of it. And found that text starts to display from some height above the text input box and buttons. I need it to be displayed right above the buttons and text input box immediately. And in my code, text for both send and receive buttons are getting displayed on left hand side. Please tell me why it is so.
    Here is the .kv file
    : size_hint_x : None size_hint_y : None pos : 0,0 text_size: self.width, None height: self.texture_size[1] halign: 'left' valign: 'middle'

         :
              font_size : 25
              size_hint : 0.1,0.1
    
         :
              GridLayout:
                  #size : root.width, root.height
                  #orientation : 'horizontal'
                  #pos:100,100
                  cols:1
                  row:3
    
                  RecycleView:
                      id: rv
                      viewclass: 'ChatBox'
    
                      RecycleBoxLayout:
                          default_size_hint: 1, None
                          orientation: 'vertical'
    
                  BoxLayout:
                      TextInput:
                          hint_text: 'type here'
                          id : txt
                          multiline : True
                          size_hint : .5,.1
                          #pos : 0,0
                      CustomButton:
                          text: 'Receive'
                          on_press : root.send_txt()
                          #pos : 10,0
                      CustomButton:
                          text: 'Send'
                          on_press : root.send_txt()
                          #pos : 20,0    
    

    Apart from that, when screen gets filled with the text and moved upwards completely, all the text disappears and if we again send or receives new text, it doesn't appear on the screen. Sir please tell me how to solve this issue. Thanking you.

提交回复
热议问题