Have Android EditText extend upwards instead of do

2019-08-12 23:07发布

I have a chat layout that's somewhat similar to Facebook's and Yahoo! Messenger's, i.e. a Fragment header, a ListView of messages, and a RelativeLayout footer, which has an EditText and a bunch of Buttons.

[            HEADER            ]
 ______________________________
|                              |
|                              |
|                              |
|                              |
|           Messages           |
|                              |
|                              |
|                              |
|                              |
|______________________________|
[BTN][    EditText   [IMG]][BTN]

When I type in long text, I want this:

[            HEADER            ]
 ______________________________
|                              |
|           Messages           |
|______________________________|
      ____________________
     |      EditText      |
     |                    |
     |                    |
     |                    |
[BTN][               [IMG]][BTN]

but instead, I get this:

[            HEADER            ]
 ______________________________
|                              |
|           Messages           |
|______________________________|
      ____________________
[BTN]|    EditText   [IMG]|[BTN]
     |                    |
     |                    |
     |                    |
     [                    ]

I tried setting the layout's gravity="BOTTOM", but that didn't work. I tried using layout_alignParentBottom="true", but that made the footer take up the entire screen.

Any suggestions?

1条回答
Rolldiameter
2楼-- · 2019-08-12 23:23

Fixed by using a LinearLayout, android:gravity="bottom", and wrapping the EditText and some other stuff into a RelativeLayout.

查看更多
登录 后发表回答