I'm creating an IM client/server application for the Android OS, and am currently putting together the user interface. Right now, my interface consists of a EditText
element, and a Button
element. When I tap on the EditText
element, a keyboard pops up and allows you to type.
What I would like to have is something like the text entry area and send button in the default Android SMS app. Something like this: The text input field and Send button would stay at the bottom of the screen, and when tapped on, the keyboard would push the text field and button up above it.
Is this possible using only EditText
and Button
elements?
Thank you for any suggestions or advice!
Is this possible using only EditText and Button elements?
Answer-This type of functionality is possible in any type of view
I give just short tutorial on your question Generally we use only linearlayout in xml file.But at view level android gives many more feature like Relative layout and much more.At this time we just discuss about the relative layout because it can solve your purpose.
In Relative layout it not use the android:orientation feature like linear layout it used another feature.In relative layout take some points in your mind...
for alignment of any view we used android:layout_toLeftOf="@id/givesname" same for
right,above and below where givesname=id of that view from which this view is align.
Ex. is gives example with screen shot
After this i give the sample xml file in which you get the above type of feature in your question
ScreenShot of above example
In this Example we used android:layout_alignParentBottom="true" - this attribute is the main reason for view like this,it always align any view in bottom even softkeyboard is shown.it contain boolean value,true gives always align bottom and false nothing.
the other relative attribute is android:layout_alignParentRight="true",android:layout_alignParentLeft="true" ,android:layout_alignParentTop="true"-all attribute give feature as written.
Lastly you include this xml file at any java file through setContentView(xmlFileName)
Try setting
android:windowSoftInputMode=adjustResize
for the activity in AndroidManifest.xml.You can find details here.