AutoCompleteTextView drop-down appears above the edit field instead of beneath - android

I have an AutoCompleteTextView, which drop-down appears above the view instead of below. Can someone help me and explain the reason of this? Can it be fixed without changing the layout too much?
Here is the part of my layout which includes mentioned AutoCompleteTextView:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/LinearNewSearch"
android:layout_width="wrap_content"
android:layout_height="60dip"
android:layout_alignParentRight="true"
android:gravity="right"
android:orientation="horizontal" >
<TextView
android:id="#+id/TextView16"
android:layout_width="35dip"
android:layout_height="wrap_content"
android:gravity="center"
android:text="0.0"
android:textColor="#ffa500"
android:textSize="18sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" = "
android:textColor="#00ff00"
android:textSize="17sp"
android:textStyle="bold" />
<EditText
android:id="#+id/EditText17"
android:layout_width="45dip"
android:layout_height="fill_parent"
android:focusable="false"
android:gravity="center"
android:inputType="numberDecimal"
android:text="0.0" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" x "
android:textColor="#00ff00"
android:textSize="17sp"
android:textStyle="bold" />
<AutoCompleteTextView
android:id="#+id/NewSearch"
android:layout_width="190dip"
android:layout_height="fill_parent"
android:layout_marginRight="10dip"
android:completionThreshold="1"
android:dropDownHeight="120dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/NewList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#id/LinearNewSearch"
android:layout_marginRight="5dip"
android:layout_marginTop="-7dip"
android:gravity="top"
android:orientation="horizontal" >
<Button
android:id="#+id/AddNewSearch"
android:layout_width="50dip"
android:layout_height="50dip"
android:layout_gravity="center"
android:layout_marginBottom="25dip"
android:layout_marginRight="5px"
android:text="+"
android:textColor="#000080"
android:textSize="15sp"
android:textStyle="bold" />
<VerticalSeekBar
android:id="#+id/seekbar2"
android:layout_width="wrap_content"
android:layout_height="150dip"
android:layout_marginRight="8px"
android:max="10"
android:progress="1" />
<LinearLayout
android:id="#+id/LinearLayout80"
android:layout_width="210dip"
android:layout_height="150dip"
android:layout_marginRight="15dip"
android:background="#25FFFFFF"
android:orientation="vertical" >
<ListView
android:id="#+id/List06"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
I've seen a suggestion to add android:dropDownHeight="100dp" to AutoCompleteTextView declaration, but that didn't help.

Try adding dropDownVerticalOffset attribute to AutoCompleteTextView in your xml:
...
<AutoCompleteTextView
android:id="#+id/NewSearch"
android:layout_width="190dip"
android:layout_height="fill_parent"
...
android:dropDownVerticalOffset="50dp"
...
/>
...

Related

Show only on item in Listview

Android List view show only one item when i am using scroll view on the List view I want to scroll listview when keyboard appears. So i am using Scroll view But it's show only one Item-
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/rel_jobDesc1"
android:layout_width="fill_parent"
android:layout_height="70dip"
android:layout_alignParentTop="true"
android:background="#drawable/header" >
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/rel_jobDesc1"
android:orientation="horizontal" >
<CheckBox
android:id="#+id/cat1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="6dip"
android:text="CAT1"
android:textColor="#0C090A" />
<CheckBox
android:id="#+id/cat2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="6dip"
android:text="CAT2"
android:textColor="#0C090A" />
<CheckBox
android:id="#+id/cat3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="6dip"
android:text="CAT3"
android:textColor="#0C090A" />
<CheckBox
android:id="#+id/cat4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="6dip"
android:text="CAT4"
android:textColor="#0C090A" />
<CheckBox
android:id="#+id/cat5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="6dip"
android:text="CAT5"
android:textColor="#0C090A" />
</LinearLayout>
<TextView
android:id="#+id/search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="20dp"
android:layout_marginTop="150dp"
android:text="#string/serach"
android:textColor="#0C090A"
android:textSize="20sp" />
<EditText
android:id="#+id/createSearch"
android:layout_width="200dip"
android:layout_height="45dip"
android:layout_alignBaseline="#+id/search"
android:layout_alignBottom="#+id/search"
android:layout_marginLeft="10dip"
android:layout_toRightOf="#+id/search"
android:background="#android:drawable/editbox_background"
android:ems="5"
android:singleLine="true" >
</EditText>
<CheckBox
android:id="#+id/review"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/search"
android:layout_alignBottom="#+id/search"
android:layout_alignParentRight="true"
android:layout_marginRight="20dip"
android:layout_marginTop="6dip"
android:text="#string/ReviewItem"
android:textColor="#0C090A" />
<RelativeLayout
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/review"
android:layout_marginTop="20dip"
android:background="#F1F1F1"
android:orientation="horizontal"
android:padding="20dip" >
<TextView
android:id="#+id/txtItemcode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dip"
android:singleLine="true"
android:text="Item Code"
android:textColor="#0C090A"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/txtItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="60dp"
android:layout_toRightOf="#+id/txtItemcode"
android:text="Item"
android:textColor="#0C090A"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/txtItem1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="23dip"
android:text="Quantity"
android:textColor="#0C090A"
android:textSize="18sp"
android:textStyle="bold" />
</RelativeLayout>
<TextView
android:id="#+id/sentchallan"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/header"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="40dip"
android:text=" Please send the Challan first"
android:textColor="#98AFC7"
android:textSize="25sp"
android:textStyle="bold" />
<ScrollView
android:id="#+id/scrollprofile"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_above="#+id/lastbutton"
android:layout_below="#+id/header" >
<LinearLayout
android:id="#+id/listlayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ListView
android:id="#+id/createlist"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:cacheColorHint="#00000000"
android:clickable="true"
android:descendantFocusability="beforeDescendants"
android:divider="#eeeeee"
android:dividerHeight="1dip"
android:scrollingCache="true"
android:smoothScrollbar="true"
android:transcriptMode="normal" >
</ListView>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/lastbutton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#F1F1F1"
android:orientation="horizontal"
android:padding="10dip" >
<CheckBox
android:id="#+id/chReprocess"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Reprocess"
android:textColor="#0C090A" />
<Button
android:id="#+id/createsavedraft"
android:layout_width="120dip"
android:layout_height="45dip"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="10dp"
android:background="#drawable/rounded"
android:text=" Save Draft "
android:textColor="#FFFFFF"
android:textSize="18dip" />
</RelativeLayout>
This is my main Screen
But when key board appear screen goes up
But i want to scroll listview when keyboard appear
Please Suggest me how can show all item in listview
Thanks In Advance
In menifest add android:windowSoftInputMode in particular activity like this-
<activity ...
android:windowSoftInputMode="stateHidden|adjustResize|adjustPan">
</activity>
Or
<activity ...
android:windowSoftInputMode="">
</activity>
one of both options will work.
Happy Coding :)

Android - EditText's hint changes View/Layout's size

I have a LinearLayout consisting of 3 LinearLayout's consisting of 2 TextView's and an EditText. When I add a hint to the third EditText I end up with a lot of whitespace between the 2nd and 3rd TextViews and also after the 3rd.
Code and images are below. What could be causing this?
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:id="#+id/self"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/name"
android:layout_marginLeft="5dp"
android:padding="5dp"
android:textSize="22sp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Sample Name"
android:padding="5dp"
android:id="#+id/self_name_show"
android:textSize="22sp"
android:textColor="#0099CC"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:id="#+id/self_name_edit"
android:inputType="text"
android:hint="#string/enter_name"
/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/address"
android:layout_marginLeft="5dp"
android:padding="5dp"
android:textSize="22sp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Sample Address"
android:padding="5dp"
android:id="#+id/self_address_show"
android:textSize="22sp"
android:textColor="#0099CC"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/self_address_edit"
android:visibility="gone"
android:inputType="text"
android:hint="#string/enter_address"
/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/phone"
android:layout_marginLeft="5dp"
android:padding="5dp"
android:autoLink="all"
android:textSize="22sp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Sample Phone"
android:padding="5dp"
android:id="#+id/self_phone_show"
android:textSize="22sp"
android:textColor="#0099CC"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/self_phone_edit"
android:phoneNumber="true"
android:hint="#string/enter_phone"
/>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="#string/edit"
android:id="#+id/edit_self_button"
android:onClick="toggleSelfEdit"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="#string/update"
android:id="#+id/update_self_button"
android:visibility="gone"
/>
</LinearLayout>
Without hint:
With hint:
I think you forgot writing the android:visibility="gone" at the third edittext. I tried your xml and when I put visibility="gone" inside the edittext your xml looks like the first screenshot :)

How to align image at extreme left of listitem?

I have an ImageView (android:id="#+id/unreadmail) which i want to show on extreme left of ListItem as shown in image. But it is not aligning properly. Any idea if i am missing anything ?
<LinearLayout
android:id="#+id/Text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/emailsubject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center"
android:singleLine="true"
android:text="abcd"
android:textColor="#444444"
android:textSize="18sp" />
<TextView
android:id="#+id/emailcontent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/emailsubject"
android:layout_below="#id/emailsubject"
android:ellipsize="marquee"
android:gravity="center"
android:singleLine="true"
android:text="defg"
android:textColor="#444444"
android:textSize="14sp" />
</LinearLayout>
<ImageView
android:id="#+id/unreademail"
android:layout_width="2dip"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/emailsubject"
android:layout_centerVertical="true"
android:background="#8A6175"
android:visibility="invisible" />
<TextView
android:id="#+id/rcvdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:paddingRight="20dip"
android:textColor="#313132"
android:textSize="12sp" />
Use this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
tools:context=".MainActivity"
tools:ignore="ObsoleteLayoutParam,ContentDescription,UselessLeaf,UselessParent" >
<LinearLayout
android:id="#+id/Text"
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal" >
<ImageView
android:id="#+id/unreademail"
android:layout_width="15dip"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#drawable/ic_launcher"
android:visibility="visible" />
<LinearLayout
android:id="#+id/Text"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_marginLeft="20dp"
android:orientation="vertical" >
<TextView
android:id="#+id/emailsubject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center"
android:singleLine="true"
android:text="abcd"
android:textColor="#444444"
android:textSize="18sp" />
<TextView
android:id="#+id/emailcontent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/emailsubject"
android:layout_below="#id/emailsubject"
android:ellipsize="marquee"
android:gravity="center"
android:singleLine="true"
android:text="defg"
android:textColor="#444444"
android:textSize="14sp" />
</LinearLayout>
<RelativeLayout
android:id="#+id/Text1"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:gravity="right"
android:layout_gravity="right"
android:orientation="horizontal" >
<TextView
android:id="#+id/rcvdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="35dp"
android:text="Date"
android:textColor="#000"
android:textSize="12sp" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
I think you should be using a relative layout at the top level (possibly not included in your code).
You cannot use 'to the left of' when the elements are at different levels in the heirarchy.
Thus I would start with your little icon left aligned to the parent and put the edit box (in the same relative view) 'to the right of' the icon.
This is the code sample for you there is no need to write the weight property if add the screenshot or the supported image how exactly you want then i can give you proper answer
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="#+id/Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/unreademail"
android:layout_marginLeft="10dip"
android:orientation="vertical">
<TextView
android:id="#+id/emailsubject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center"
android:singleLine="true"
android:text="abcd"
android:textColor="#444444"
android:textSize="18sp" />
<TextView
android:id="#+id/emailcontent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/emailsubject"
android:layout_below="#id/emailsubject"
android:ellipsize="marquee"
android:gravity="center"
android:singleLine="true"
android:text="defg"
android:textColor="#444444"
android:textSize="14sp" />
</LinearLayout>
<ImageView
android:id="#+id/unreademail"
android:layout_width="2dip"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:layout_marginBottom="5dip"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="#8A6175"
android:visibility="invisible" />
<TextView
android:id="#+id/rcvdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:paddingRight="20dip"
android:textColor="#313132"
android:textSize="12sp" />
</RelativeLayout>

android how to add separator in headerlayout?

I want to add separator in between button and textview in my layout header contains 2 buttons and textview how do I add separator in between them?
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="50px"
android:layout_gravity="fill_horizontal"
android:background="#color/Blue"
android:orientation="horizontal" >
<Button
android:id="#+id/Back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:background="#color/Blue"
android:textSize="20sp"
android:textColor="#color/White"
android:text=" Back"
/>
<TextView
android:id="#+id/header_text"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:layout_toLeftOf="#+id/Exit"
android:layout_toRightOf="#+id/Back"
android:textSize="20sp"
android:textStyle="italic"
android:typeface="serif"
android:background="#color/Blue"
android:textColor="#color/White"
android:text="Games Apps"/>
<Button
android:id="#+id/Exit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textSize="20sp"
android:layout_centerVertical="true"
android:background="#color/Blue"
android:textColor="#color/White"
android:layout_marginRight="5dp"
android:text=" Exit"
/>
</RelativeLayout>
Seems that you need a vertical separator:
<TextView
android:layout_width="2dp"
android:layout_height="fill_parent"
android:layout_toLeftOf="#id/header_text"
android:layout_toRightOf="#id/Back"
android:background="#00000000"
/>
add View between your button and textview
For instance
<View
android:layout_width="2dip"
android:layout_height="fill_parent"
android:layout_toLeftOf="#id/header_text"
android:layout_toRightOf="#id/Exit"
android:padding = "5dip"
android:background="#FFFF0000"
/>
May this help you..
To add seperator you have to add a view in between the objects you want seperator..
like..
<View
android:layout_width="2dip"
android:layout_height="fill_parent"
android:layout_toLeftOf="#id/header_text"
android:layout_toRightOf="#+id/Back"
android:padding = "5dip"
android:background="#FFFF0000"
/>
and change this lines in your code..
<TextView
android:id="#+id/header_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_toLeftOf="#+id/Exit"
android:layout_toRightOf="#+id/Back"
android:textSize="20sp"
android:textStyle="italic"
android:typeface="serif"
android:background="#color/Blue"
android:textColor="#color/White"
android:text="Games Apps"/>
or you can use <TableRow> </TableRow> try to put the whole code with seperator in between the views
Try this, just workaround worked for me. You can use the same logic by implementing other Layout to instead of TableLayout.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:stretchColumns="*"
android:showDividers="middle"
android:layout_centerInParent="true"
android:background="#000000"
android:divider="#000000"
>
<TableRow>
<Button
android:id="#+id/Back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:background="#ffffff"
android:textSize="20sp"
android:text=" Back"
/>
<TextView
android:id="#+id/header_text"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:layout_toLeftOf="#+id/Exit"
android:layout_toRightOf="#+id/Back"
android:textSize="20sp"
android:layout_marginLeft="1dp"
android:textStyle="italic"
android:background="#ffffff"
android:typeface="serif"
android:text="Games Apps"/>
<Button
android:id="#+id/Exit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textSize="20sp"
android:layout_marginLeft="1dp"
android:background="#ffffff"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:text=" Exit"
/>
</TableRow>
</TableLayout>
</RelativeLayout>
Let me know you have other difficulties use this.

ListView pushes button out of screen

I'm trying to get the ListView to remain the same size even if it overflows. However, once the ListView overflows, it pushes the buttons below off the screen. How do I prevent it from pushing other elements that are below it?
As you can see from the above images, the second shows that the buttons get pushed off the screen once the ListView overflows.
XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#color/splash_bg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:background="#color/splash_bg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="10dp"
android:orientation="vertical" >
<TextView
android:id="#+id/subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="20sp"
android:paddingBottom="10dp"
android:textColor="#color/splash_text"
android:text="#string/sub" />
<EditText
android:id="#+id/grp_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/field1"
android:lines="1" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/members"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textSize="15sp"
android:paddingTop="5dp"
android:textColor="#color/splash_text"
android:text="#string/members" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/splash_bg"
android:orientation="horizontal" >
<EditText
android:id="#+id/name"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="#string/field2" />
<Button
android:id="#+id/add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/add" />
</LinearLayout>
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:background="#color/splash_bg" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="bottom"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingBottom="5dp"
android:paddingTop="10dp" >
<Button
android:id="#+id/save_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="5"
android:text="Save" />
<Button
android:id="#+id/cancel_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cancel" />
</LinearLayout>
Changet
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:background="#color/splash_bg" />
to
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:paddingLeft="5dp"
android:background="#color/splash_bg" />
You can use a relative layout for this. Modify the below according to your needs
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginRight="11dp"
android:layout_marginTop="11dp"
android:text="Create New Group" />
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/textView1"
android:layout_marginTop="23dp"
android:ems="10"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/editText1"
android:layout_marginLeft="11dp"
android:layout_marginTop="18dp"
android:text="Members" />
<EditText
android:id="#+id/editText2"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/textView1"
android:layout_below="#+id/textView2"
android:layout_marginTop="31dp"
android:ems="10" />
<ListView
android:id="#android:id/list"
android:layout_above="#+id/button1"
android:layout_below="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
/>
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/editText2"
android:layout_alignBottom="#+id/editText2"
android:layout_alignParentRight="true"
android:layout_marginRight="13dp"
android:text="ADD" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/button3"
android:layout_below="#android:id/list"
android:text="Cancel" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="#+id/textView1"
android:text="Save" />
</RelativeLayout>
I added this line : android:layout_weight="1" to the LinearLayout where EditText exist (my problem source) and the problem is gone !
look at the code where I commented <!-- HERE!!! -->
LOL I know i'm very late to answer this Q ,, sorry ,, but for anyone who is still struggling !
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="#+id/linearLayout1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="ID : "
android:layout_margin="#dimen/EdgeMargins"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="#+id/editText"
android:layout_margin="#dimen/EdgeMargins"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/linearLayout2"
android:layout_weight="1"> <!-- HERE!!! -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Any Notes :"
android:id="#+id/textView2"
android:layout_margin="#dimen/EdgeMargins"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/editText2"
android:layout_margin="#dimen/EdgeMargins" />
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Done"
android:id="#+id/button"
android:layout_margin="#dimen/EdgeMargins" />
</LinearLayout>
i had my problem with the highlighted EditText in the pic ,,, it expands with the entered text and pushes the DONE Button down !
I know my solution may look so silly but I took a whole day to solve this !
Hope it helps ^_^ GL

Categories

Resources