Skip to content Skip to sidebar Skip to footer

Android Text Input Special UI Item

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

Solution 1:

Try setting android:windowSoftInputMode=adjustResize for the activity in AndroidManifest.xml.

You can find details here.


Solution 2:

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...

  1. we always give id to every view using android:id="@+id/GiveName"
  2. 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

  <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/llWriteCommentWall" android:layout_height="fill_parent"
      android:layout_width="fill_parent" android:background="#ffffff">
      <Button android:id="@+id/btButtonComments"
        android:layout_height="wrap_content"     
        android:layout_width="wrap_content"        
        android:text="Comments" 
        android:layout_alignParentRight="true"  
        android:layout_alignParentBottom="true"/>
      <EditText android:id="@+id/etEdittext"
        android:layout_height="wrap_content" android:layout_width="fill_parent"
        android:hint="Write a comment....   "
        android:layout_marginLeft="2dip" android:layout_marginRight="2dip" 
        android:layout_toLeftOf="@id/btButtonComments" 
        android:layout_alignParentBottom="true"/>
    </RelativeLayout>

ScreenShot of above example

At Simple Mode At Click on Edittext

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)


Post a Comment for "Android Text Input Special UI Item"