I've got a popup layout inflator with EditText fields. It is opened inside my activity when a button is pressed. I then ask for input information through the popup window. When I press any of the EditText fields the keyboard doesn't display. Does the popup View not support interaction?
Here is my xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#android:color/background_light">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_margin="1dp"
android:background="#android:color/darker_gray">
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Fill in the information." />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Field ID or Name"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/fieldname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_below="#+id/textView1"
android:ems="10" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/enterWidth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Width of Implement - Feet or Meters"
android:layout_below="#+id/fieldname"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/width"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:layout_below="#+id/enterWidth"
android:inputType="numberDecimal" />
<TextView
android:id="#+id/units"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Units"
android:layout_below="#+id/width"
android:textAppearance="?android:attr/textAppearanceMedium" />
<RadioGroup
android:id="#+id/radiogroup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/units"
android:orientation="vertical">
<RadioButton android:id="#+id/standard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Standard - feet, ac, mph"
android:onClick="onRadioButtonClicked"/>
<RadioButton android:id="#+id/metric"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Metric - m, ha, kph"
android:onClick="onRadioButtonClicked"/>
</RadioGroup>
<TextView
android:id="#+id/comments"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Field Comments"
android:layout_below="#+id/radiogroup"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/commentlines"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/comments"
android:ems="10"
android:inputType="textMultiLine" />
</RelativeLayout>
<Button
android:id="#+id/startbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Begin Spraying" />
</LinearLayout>
</LinearLayout>
After digging I found this similar post:
EditText On A Popup Window
The key is to make the PopupWindow focusable.
This can be done by:
popupWindow.setFocusable(true);
Related
I am trying to add an edittext above a listview. The edittext field gets displayed, however, it is repeated for each row in the listview as well, which I don't want.
I have tried placing it outside the first inner LinearLayout but there is no difference in the behaviour.
Can someone please help me to figure out what I might be doing wrong.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/llMain"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.1"
android:orientation="vertical">
<EditText
android:id="#+id/searchString"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableRight="#drawable/abc_ic_clear_holo_light"
android:ems="10"
android:hint="Search for..."
android:text="" >
</EditText>
<ListView
android:id="#+id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:padding="3sp" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/tvCategory"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:paddingRight="1sp"
android:text=""
android:textColor="#FFFFFF"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/tvCategory"
android:paddingRight="1sp"
android:text=""
android:textColor="#000000"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textView7"
android:paddingRight="1sp"
android:text=""
android:textColor="#000000"
android:textSize="14sp" />
<TextView
android:id="#+id/textView8"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#id/textView5"
android:gravity="right"
android:paddingRight="1sp"
android:text=""
android:textColor="#000000"
android:textSize="16sp" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/idAdView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:layout_weight="1"
android:orientation="vertical" />
</LinearLayout>
Try adding the edit text as header view to the list.
public void addHeaderView (View v)
Ref : http://developer.android.com/reference/android/widget/ListView.html#addHeaderView(android.view.View)
I want to create a Layout that have the feature of expand and collapse .Expand should be like that at a time only one row can be expanded ,if user clicks on other first should be closed by itself.In each row i have to show different layout design .
Please help me in this ,i have searched but i am not getting i how could i create this functionality .Please take this as a reference how it will be like .Please suggest me the best approach to get this
You can use a lib Accordion-View screenshot is :
I have implemented some code as the answer suggested by #Super User. So from that i think you will sure get your solution.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:accordion="http://schemas.android.com/apk/res-auto/com.sentaca.android.accordion"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#android:color/white"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/main_header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#ff0000"
android:orientation="horizontal" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Offline Booking Request"
android:textColor="#fff"
android:textStyle="bold" />
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<com.sentaca.android.accordion.widget.AccordionView
android:id="#+id/accordion_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
accordion:header_layout_fold_button_id="#id/foldButton"
accordion:header_layout_id="#layout/accordion_header"
accordion:header_layout_label_id="#id/foldText"
accordion:section_bottom="#layout/accordion_footer"
accordion:section_container="#layout/accordion_section"
accordion:section_container_parent="#id/section_content"
accordion:section_headers="#array/accordion_sections"
accordion:section_visibility="#array/accordion_visibility"
android:background="#fff5f5f5"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Please specify offline car details if you need any cars of travels"
android:textSize="14sp" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="45dp"
android:text="Plase click the checkbox to send the details"
android:textColor="#ff0000" />
<include layout="#layout/radio" >
</include>
</LinearLayout>
<LinearLayout
android:id="#+id/example_get_by_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item 2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item 3" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item 4" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RatingBar
android:id="#+id/ratingBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:id="#+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<SeekBar
android:id="#+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item 4" />
</com.sentaca.android.accordion.widget.AccordionView>
</ScrollView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Review" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Confirm" />
</LinearLayout>
</LinearLayout>
Now just remember one thing whenever you want to add layout items then add item in Linear Layout and make different layout for different sections and after that include that layout in your Linear layout. I have tried for one section named radio.xml file which is included in Linear Layout above.
radio.xml
<?xml version="1.0" encoding="utf-8"?>
<RadioGroup
android:id="#+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/radio0"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:checked="true"
android:text="Domestic"
android:textColor="#ff0000" />
<RadioButton
android:id="#+id/radio1"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:text="InterNational"
android:textColor="#ff0000" />
</RadioGroup>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Pick Up Location"
android:textAppearance="?android:attr/textAppearanceSmall" />
<EditText
android:id="#+id/editText1"
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_weight="1"
android:ems="10" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="DropLocation"
android:textAppearance="?android:attr/textAppearanceSmall" />
<EditText
android:id="#+id/editText2"
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_weight="1"
android:ems="10" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:text="Car Type"
android:textColor="#000" />
<Spinner
android:id="#+id/spinner1"
android:layout_width="0dp"
android:layout_height="35dp"
android:layout_gravity="center"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:text="Remarks"
android:textColor="#000" />
<EditText
android:id="#+id/editText3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textMultiLine" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
You can start with ExpandableListView and customize it to your need. I think this would be a good way to start. Please follow a link below to customize ExpandableListView :
http://androidexample.com/Custom_Expandable_ListView_Tutorial_-_Android_Example/index.php?view=article_discription&aid=107&aaid=129
You can google for more links on customizing expandablelistview. Hope it helps.
You can use scaleAnimation where you can add in each section a layout panel and inside the layout textview or anything as your requirement. See this. Hope it might help you.
http://wwwpriyaandroid.blogspot.in/2013/10/accordion.html
I have 3 edit texts on a screen. On small screen devices before touching a edittext my screen looks like
And after touching first edittext(e.g. in front of name), keyboard popup comes, and it looks
i.e. now edittext Amount(which in front of TextView named Amount) is now in front of the user. But as I have touched(or clicked) first(Name) edittext, I want it in front of the user. But no matter which I select every time Amount is in front.
I have tried using requestFocus() and setSelect(true). Even has focus returns true, but nothing works.
So how to do that?
I have given scroll view to the tablelayout which contains these three edittexts and three text boxes in front of them.
my xml code is
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/rl_upload_header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:minHeight="50dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/selected_image_detail"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/rl_upload_top"
android:layout_width="fill_parent"
android:layout_height="150dp"
android:layout_weight="4"
android:baselineAligned="false"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:id="#+id/image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:contentDescription="#string/empty" >
</ImageView>
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="2"
android:gravity="center" >
<TableLayout
android:id="#+id/tableLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="5dip" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/name_table" />
<EditText
android:id="#+id/ed_img_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="#drawable/text_box_background"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="#string/name"
android:paddingLeft="5dip" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="5dip" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/amount_table" />
<EditText
android:id="#+id/ed_amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="#drawable/text_box_background"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="#string/amount"
android:paddingLeft="5dip" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="5dip" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/desc_table" />
<EditText
android:id="#+id/ed_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="#drawable/text_box_background"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="#string/desc"
android:paddingLeft="5dip" />
</TableRow>
</TableLayout>
</ScrollView>
<LinearLayout
android:id="#+id/rl_upload_bottom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:gravity="center"
android:minHeight="70dp" >
<Button
android:id="#+id/button_update"
android:layout_width="150dp"
android:layout_height="40dp"
android:background="#drawable/btn_update" >
</Button>
</LinearLayout>
Add below line to manifest for related activity,
android:windowSoftInputMode="adjustPan"
Well the title speaks for it self. I suspect it has to do with the ScrollView but cannot figure this out. I want the LinearLayout content to stay aligned to the bottom.
Her's my xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollViewActivityLogin"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<RelativeLayout android:id="#+id/relativeLayout_top_activity_login"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#color/blue"
android:focusable="true"
android:focusableInTouchMode="true">
<TextView
android:id="#+id/txt_head_activity_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginLeft="25dip"
android:layout_marginRight="25dip"
android:layout_marginTop="20dip"
android:text="#string/string_your_not_logged_on"
android:textSize="22sp" />
<TextView
android:id="#+id/txt_username_activity_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_head_activity_login"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dip"
android:text="#string/string_user_name"
/>
<EditText
android:id="#+id/edt_username_activity_login"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_username_activity_login"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:singleLine="true"
android:inputType="text"/>
<TextView
android:id="#+id/txt_password_activity_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/edt_username_activity_login"
android:layout_centerHorizontal="true"
android:text="#string/string_password"
/>
<EditText
android:id="#+id/edt_password_activity_login"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_password_activity_login"
android:layout_centerHorizontal="true"
android:layout_marginLeft="15dip"
android:layout_marginRight="15dip"
android:singleLine="true"
android:inputType="textPassword"
/>
<Button
android:id="#+id/btn_login_activity_login"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:layout_below="#+id/edt_password_activity_login"
android:layout_centerHorizontal="true"
android:layout_marginLeft="25dip"
android:layout_marginRight="25dip"
android:layout_marginTop="20dip"
android:text="#string/string_login" />
<Button
android:id="#+id/btn_sign_up_activity_login"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:layout_below="#+id/btn_login_activity_login"
android:layout_centerHorizontal="true"
android:layout_marginLeft="25dip"
android:layout_marginRight="25dip"
android:layout_marginTop="50dip"
android:text="#string/string_sign_up" />
<LinearLayout android:id="#+id/linearLayout_bottom_activity_login"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:layout_marginBottom="20dp"
>
<TextView
android:id="#+id/txt_version_activity_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="" />
<TextView
android:id="#+id/txt_copywrite_activity_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="#string/string_app_name_copywrite" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
please change at top of the file like this.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollViewActivityLogin"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true" >
<RelativeLayout android:id="#+id/relativeLayout_top_activity_login"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#color/blue"
android:focusable="true"
android:focusableInTouchMode="true">
see this Image you will get more idea
http://i.stack.imgur.com/uOai7.jpg
I have a problem on the EditText. I cannot show all the EditText field when the soft keyboard is showing, just like the following image:
And the following is my layout code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="15dip"
android:focusable="true" >
<TextView
android:id="#+id/password_listing"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:text="#string/new_service"
android:textSize="20dip"
android:textStyle="bold"
android:padding="10dip" />
<RelativeLayout
android:id="#+id/l_service_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_vertical" >
<TextView
android:id="#+id/service_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:gravity="center_vertical"
android:text="#string/service_name"
android:textSize="15dip"
android:textStyle="bold" />
<EditText
android:id="#+id/servicename"
android:layout_width="180dip"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:gravity="center_vertical|center_horizontal"
android:hint=""
android:singleLine="true"
android:focusable="true" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/l_username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_vertical" >
<TextView
android:id="#+id/user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:gravity="center_vertical"
android:text="#string/username"
android:textSize="15dip"
android:textStyle="bold" />
<EditText
android:id="#+id/username"
android:layout_width="180dip"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:gravity="center_vertical|center_horizontal"
android:hint=""
android:singleLine="true"
android:focusable="true" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/l_pwd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_vertical" >
<TextView
android:id="#+id/pwdset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:gravity="center_vertical"
android:text="#string/pwd_txt"
android:textSize="15dip"
android:textStyle="bold" />
<EditText
android:id="#+id/pwd_set"
android:layout_width="180dip"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:gravity="center_vertical|center_horizontal"
android:hint=""
android:inputType="textPassword"
android:isScrollContainer="true"
android:focusable="true" />
</RelativeLayout>
<LinearLayout
android:id="#+id/layout_3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_vertical|center_horizontal" >
<TextView
android:id="#+id/selectmsg_txt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:text="#string/selectmsg"
android:textSize="15dip"
android:textStyle="bold" />
<GridView
android:id="#+id/app_grid"
android:layout_width="match_parent"
android:layout_height="150dp"
android:padding="10dp"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:numColumns="auto_fit"
android:columnWidth="60dp"
android:stretchMode="columnWidth"
android:gravity="center" />
<Button
android:id="#+id/b_addpwd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:text="#string/add"
android:background="#android:color/transparent"
android:drawableLeft="#drawable/ic_add"
android:textColor="#android:color/white"
android:textSize="20dip" />
</LinearLayout>
</LinearLayout>
Since I want it auto-hidden the soft keyboard when I enter this activity, so I added this into my activity:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
What is the problem with my layout xml?
use a scroll view and also add following in the activity tag in manifest file:
android:windowSoftInputMode="adjustPan"
Use the following code snippet in your manifest file :
android:windowSoftInputMode="adjustResize|adjustPan"
What helped me is this:
EditText et = new EditText(); //or whatever way you use to fetch the object
et.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
Hope it'll help you as well