I need to arrange two ListViews in a vertical LinearLayout in such a way that 2nd ListView will be at the end of last item of first ListView.
If ListView1 is empty, the view should be something like this.
As ListView1.size() increases ListView2 should be pulled down to a limit.
ListView1 reaches a fixed height (or weight) , it should stop expanding and start scrolling.
I think there is no method in android to set maxHeight for View.
I have already tried almost all combinations of layout_height="wrap_content", fixed heights and weights for both ListViews. In all cases,
either 1st requirement(image1) will fail : ListView1 will not be at top
or last requirement(image3) will fail : ListView2 will get pushed out of the screen.
Any help or suggestions will be appreciated. Thanks in advance.
Edit:
my current code is:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1" >
<ListView
android:id="#+id/myOrderListView"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.6" >
</ListView>
<ListView
android:id="#+id/myCompletedOrderListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_weight="0.4" >
</ListView>
</LinearLayout>
I have tried with different weight combinations, like:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1" >
<ListView
android:id="#+id/myOrderListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.6" >
</ListView>
<ListView
android:id="#+id/myCompletedOrderListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_weight="0.4" >
</ListView>
</LinearLayout>
But it will fail last requirement.
Edit2: #dangVarmit
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1" >
<ListView
android:id="#+id/myOrderListView"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
<ListView
android:id="#+id/myCompletedOrderListView"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="20dp" >
</ListView>
<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
If you mean this, It still fails req3.
You can find the below code for right and left listview you can change it to above and bottom listview or as you want to show
main_activity.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="#+id/main_top_bit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/orange">
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:orientation="horizontal">
<Button
android:id="#+id/button_1"
style="#style/landscape_top_button"
android:text="button1" />
<Button
android:id="#+id/button_2"
style="#style/landscape_top_button"
android:text="button2"/>
</LinearLayout>
</LinearLayout>
<View android:id="#+id/main_horizontal_bar"
android:layout_height="3dip" android:layout_width="fill_parent"
android:background="#color/gray" android:layout_marginTop="1dip" />
</LinearLayout>
<LinearLayout
android:id="#+id/lower_linear_layout"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/main_top_bit">
<RelativeLayout
android:layout_below="#+id/lower_linear_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="150dip"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#color/teal"
android:id="#+id/org_left_linearlayout2">
<Button
android:id="#+id/button_3"
style="#style/landscape_top_button"
android:text="button3"/>
<Button
android:id="#+id/button_4"
style="#style/landscape_top_button"
android:text="button4" />
</LinearLayout>
<ListView
android:background="#color/green"
android:id="#+id/lstLeft"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/org_left_linearlayout2"
android:layout_above="#+id/org_left_bottom_rl"
android:cacheColorHint="#00000000"/>
<RelativeLayout
android:id="#+id/org_left_bottom_rl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/purple" >
<Button
android:text="button5"
android:id="#+id/button_5"
android:layout_alignParentLeft="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</Button>
</RelativeLayout>
</RelativeLayout>
<View
android:layout_width="3dip"
android:layout_height="fill_parent"
android:background="#color/gray">
</View>
<RelativeLayout
android:layout_below="#+id/lower_linear_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#color/olive"
android:id="#+id/org_right_linearlayout2">
<Button
android:id="#+id/button_6"
style="#style/landscape_top_button"
android:text="button6" />
<Button
android:id="#+id/button_7"
style="#style/landscape_top_button"
android:text="button7" />
</LinearLayout>
<ListView
android:id="#+id/lstRight"
android:background="#color/blue"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/org_right_linearlayout2"
android:layout_above="#+id/org_right_bottom_rl"
android:cacheColorHint="#00000000"/>
<RelativeLayout
android:id="#+id/org_right_bottom_rl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/red"
android:layout_alignParentBottom="true">
<Button
android:text="button8"
android:id="#+id/button_8"
android:layout_alignParentRight="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</Button>
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
MainActivity.java
public class MainActivity extends Activity {
private final String TAG = this.getClass().getName();
ListView leftList;
ListView rightList;
static final String[] FRUITS = new String[] {"Apple", "Bananna", "Cherry", "Pear", "Strawberry"};
static final String[] VEGETABLES = new String[] {"Asparagus", "Bamboo shoots", "Celery", "Ginger", "Spinach"};
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
leftList = (ListView) findViewById(R.id.lstLeft);
rightList = (ListView) findViewById(R.id.lstRight);
populateLeftList();
populateRightList();
}
public void populateLeftList(){
leftList.setAdapter(new ArrayAdapter<string>(this, android.R.layout.simple_list_item_1, FRUITS));
}
public void populateRightList(){
rightList.setAdapter(new ArrayAdapter<string>(this, android.R.layout.simple_list_item_1, VEGETABLES));
}
}
for list1, layout_height=wrap_content, remove layout_weight
for list2, layout_height=100dp (any fixed value), remove layout_weight
add <Space layout_weight=1 layout_height=0dp/> at the end of the list.
that should give you the results you are looking for.
I have found one solution by myself. It works perfectly as i wanted. I dont know whether it is a good approach or not. I am searching for an xml solution.
getDeviceHeight() is my method to find device height in pixels.
200 is the approximate height of other ui elements above My ListViews.
myorderList is my first ListView
if(myorderList.getHeight() > ((getDeviceHeight()/2) - 200)) {
LayoutParams params = myorderList.getLayoutParams();
params.height = (int)((getDeviceHeight()/2) - 200);
myorderList.setLayoutParams(params);
}
This should be done when there is any kind of changes happening to the first ListView.
Edit:
This will also fail when items removed after reaching maximum height :-(
Related
I have started building an app with two ListView's under each other.
Now i put an ScrollView over it, because the amout of itmes might get very big and therefore i want the whole layout to be scrollable and not the lists itself. But my solution dosent work!
btw: i dont want to replace my ListViews with a LinearLayout or so because then all my adapters are gone.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<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:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="#style/Heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ListView1" />
<Space
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
style="#style/ButtonStyle.SpinnerAddButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="#drawable/ic_add_black_24dp"
android:onClick="addToList1" />
</LinearLayout>
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/marginLeft"
android:layout_marginRight="#dimen/marginLeft" />
<!--Second list-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="#style/Heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ListView2" />
<Space
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
style="#style/ButtonStyle.SpinnerAddButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="#drawable/ic_add_black_24dp"
android:onClick="addToList2" />
</LinearLayout>
<ListView
android:id="#+id/listView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/marginLeft"
android:layout_marginRight="#dimen/marginLeft" />
</LinearLayout>
</ScrollView>
My Layout now shows all the ListViews under each other but only one Item per ListView and you can then scroll through this Lists.
You should should use one listview and just have different viewtypes.
#Override
public int getItemViewType(int position) {
return isFirstItem(position) ? TYPE_ITEMA : TYPE_ITEMB;
}
#Override
public int getViewTypeCount() {
return 2;
}
In my first screen shot you can see expended listview at top and textview placed at below next to expended listview.
But if you look at my second screen shot, as the listview adds more items textview place at the bottom does not appear.
My layout code is :
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/form_view"
>
<LinearLayout
android:id="#+id/relativeLayout1"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Spinner
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_weight="2"
android:id="#+id/spinnerSemester" />
<Button
android:id="#+id/graph_button"
android:layout_width="0dip"
android:layout_weight="0.7"
android:layout_height="wrap_content"
android:text="Chart" />
</LinearLayout>
<ExpandableListView
android:id="#+id/lv_attendance"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_weight="1"
android:cacheColorHint="#00000000"
>
</ExpandableListView>
<TextView
android:id="#+id/TV_note"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/lv_attendance"
android:paddingLeft="10dp"
android:text="[NOTE : The data displayed here is for advance information only. Please check with the college office/department concerned for the final and certified data. In case of discrepancies, the data maintained in the college records will be deemed to be the final one.]"
android:layout_marginTop="10px"
android:textSize="13sp" />
</LinearLayout>
Thanks,
Nandakishore P
Try as below...
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/form_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Spinner
android:id="#+id/spinnerSemester"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="2" />
<Button
android:id="#+id/graph_button"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.7"
android:text="Chart" />
</LinearLayout>
<ExpandableListView
android:id="#+id/lv_attendance"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:cacheColorHint="#00000000" >
</ExpandableListView>
<TextView
android:id="#+id/TV_note"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:paddingLeft="10dp"
android:text="[NOTE : The data displayed here is for advance information only. Please check with the college office/department concerned for the final and certified data. In case of discrepancies, the data maintained in the college records will be deemed to be the final one.]"
android:textSize="13sp" />
</LinearLayout>
consider specifyig android:layout_weight to the views, also encasing that text view in a framelayout or linearlayout
Gods, I hate layout...
Dont use android:layout_below="#+id/lv_attendance", its creating problem, use alignParentBottom instead.
I am relatively new to android programing. Can anybody tell me why my ScrollView won't scroll?
My activity has implemented OnGestureListener for getting some touch information. But, I tried to disable onGestureListener and it still won't work.
It works outside of the SlidingDrawer. Is it possible to get it work inside of the SlidingDrawer?
I solved it by giving to ScrollView ID and then put that ID in SlidingDrawer android:content="#+id/content".
<?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:layout_gravity="right"
android:background="#drawable/pozadina_touchpad"
android:orientation="vertical" >
<LinearLayout
android:layout_width="100dp"
android:layout_height="match_parent"
android:layout_gravity="right"
android:orientation="vertical" >
<SlidingDrawer
android:id="#+id/prosirenje"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:content="#+id/content"
android:handle="#+id/handle" >
<Button
android:id="#+id/handle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/gumb_slider"
/>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/slider"
android:gravity="center"
android:onClick="nemaSkrola"
android:orientation="vertical" >
<Button
android:id="#+id/ico_povecalo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:background="#drawable/ikona_povecalo" />
<Button
android:id="#+id/ico_desktop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:background="#drawable/ikona_komp" />
<Button
android:id="#+id/ico_daljinski"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:background="#drawable/ikona_play" />
<Button
android:id="#+id/ico_tipkovnica"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:background="#drawable/ikona_tipka" />
<Button
android:id="#+id/ico_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:background="#drawable/ikona_settings" />
</LinearLayout>
</ScrollView>
</SlidingDrawer>
</LinearLayout>
</LinearLayout>
give some value to scrollView's width and height and try like this
<ScrollView
android:id="#id/content"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
please change scrollview id like this:
android:id="#id/content"
please change handle button id like this:
android:id="#id/handle"
The containers (hierarchical parents) of the ScrollView have the following attribute set this way: android:layout_height="match_parent", which forces them to limit their content to the height of the activity (screen).
For your ScrollView to work, try to get the ScrollView to a higher hierarchical level, so that won't be constrained by its parent.
Good day, I have an Activity which contains 4 fragments. The Activity has a footer which I use to switch between these fragment views. Now in one of my fragments, i have some widgets and the last widget is a ListView. The trouble am having is, the last 2 entries in the Listview are not displaying correctly! they are obscured by the footer. I have set my LayoutParameters for both the width and height of the Listview to FILL_PARENT. but its not working. Any idea how i can solve this? Thanks in advance.
My Layout is :
for the fragment:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button android:id="#+id/line_button_id" android:layout_width="160dp"
android:layout_height="wrap_content" android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" android:layout_marginLeft="5dp" android:focusable="true"
android:layout_marginTop="8dp" android:text="#string/line_graph" android:background="#drawable/temp_left_button" />
<Button android:id="#+id/bar_button_id" android:layout_width="160dp"
android:layout_height="wrap_content" android:layout_alignBaseline="#+id/line_button_id"
android:layout_alignBottom="#+id/line_button_id" android:focusable="true"
android:layout_alignParentRight="true" android:layout_marginRight="5dp"
android:text="#string/bar_graph" android:background="#drawable/temp_right_button"></Button>"
<FrameLayout
android:id="#+id/graph_framelayout_id"
android:layout_width="fill_parent"
android:layout_height="280dp"
android:layout_below="#id/line_button_id"
android:padding="4dp"
android:layout_margin="4dp"
android:background="#drawable/rounded_date_filter">
</FrameLayout>
<!-- first cell information, dashboard -->
<LinearLayout
android:id="#+id/row1_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:layout_below="#id/graph_framelayout_id"
android:orientation="horizontal"
android:clickable="true"
android:background="#drawable/rounded_table_row">
<TextView
android:id="#+id/dashboard_datefrom_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:layout_marginLeft="20dp"
android:text="01 may 2012"/>
<ImageView
android:id="#+id/dashboard_image_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/ic_action_search"/>
<TextView
android:id="#+id/dashboard_dateto_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:text="01 sept 2012"/>
</LinearLayout>
<!-- accounts overview listview -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/row1_id"
android:layout_margin="4dp"
android:orientation="vertical"
android:background="#drawable/rounded_date_filter">
<TextView
android:id="#+id/list_text_header_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="2dp"
android:text="#string/data_grid_text_header_day"
android:background="#drawable/text_header">
</TextView>
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</ListView>
</LinearLayout>
</RelativeLayout>
and for the Activity i have this:
<
?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="#+id/fragment_container_id"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</FrameLayout>
<include layout="#layout/footer"></include>"
</RelativeLayout>
i replace the fragments with in the framelayout of the Activity
What Layout are you using in your Fragment, this surely won't happen if you use RelativeLayout and set above attribute to your ListView like this :
Try to add this into FrameLayout in your Activity layout.
android:layout_above="#+id/footer"
I want to have a ListView, followed by a EdiText, folowed by 2 buttons like:
ListView <NEWLINE>
EditText <NEWLINE>
Button1 Button2 <NEWLINE>
I have the code and if the list is small everything goes well. However, if the list has many elements it will take all the space and I won't be able to see the EditText or the buttons.
I have trimmed it down to the part where the problem starts:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="#+id/in"
android:layout_below="#id/button_contacts"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stackFromBottom="true"
android:transcriptMode="alwaysScroll"
android:layout_weight="1.0"
/>
<EditText
android:id="#+id/entry"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#android:drawable/editbox_background"
android:layout_below="#id/in" />
<Button
android:id="#+id/Convert"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#id/entry"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dip"
android:text="Convert" />
<Button
android:id="#+id/sendSMS"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_toLeftOf="#id/Convert"
android:layout_alignTop="#id/Convert"
android:text="Send" />
</RelativeLayout>
How can I solve this?
the below code works for me and i hope it will work for you too...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="#style/MainLinearLayout">"
<TableLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
style="#style/MainTableLayoutStyle">
<ListView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#android:id/list"
android:layout_weight="1"
android:cacheColorHint="#color/transparent"
>
</ListView>
<TableRow>
<EditText
android:id="#+id/entry"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#android:drawable/editbox_background"
android:layout_below="#id/in" />
</TableRow>
<TableRow >
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/button1"
android:text="button1"
android:layout_gravity="left"
android:layout_weight="1"
/>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/button1"
android:text="button2"
android:layout_gravity="right"
android:layout_weight="1"
/>
</TableRow>
</TableLayout>
</LinearLayout>
Because in ListView you use android:layout_weight="1.0" so, it took all space. you should add 1 layout to wrap your Text,Buttom etc. and add this android:layout_weight="2.0" or 3.0 (it's up to you) Try.
P.S. If it still not work For Try change all android:layout_height="fill_parent" To android:layout_height="wrap_content"
<ListView android:id="#+id/in"
android:layout_below="#id/button_contacts"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stackFromBottom="true"
android:transcriptMode="alwaysScroll"
android:layout_weight="1.0"
/>
<Relativelaout
android:id="#+id/bottomcontrol"
android:layout_below="#id/in"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2.0">
<EditText
android:id="#+id/entry"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#android:drawable/editbox_background"
/>
<Button
android:id="#+id/Convert"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#id/entry"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dip"
android:text="Convert" />
<Button
android:id="#+id/sendSMS"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_toLeftOf="#id/Convert"
android:layout_alignTop="#id/Convert"
android:text="Send" />
</RelativeLayout>
You need to give your listview a fixed height.
<ListView android:id="#+id/in"
android:layout_below="#id/button_contacts"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:stackFromBottom="true"
android:transcriptMode="alwaysScroll"
android:layout_weight="1.0"
/>
Another choice is to set the height programmatically in the code. If you do this you need to do in the Activity's onWindowFocused() method. You can then programmatically set it to say half your screen.
Private LinearLayout llfullscreen;//llfullscreen is the viewgroup
//that stretches the whole screen
Private ListView lv;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
llfullscreen = findViewById(R.id.bottomcontrol)
}
#Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if(hasFocus && llfullscreen!=null){
int layoutHeight = llfullscreen.getHeight();
ViewGroup.LayoutParams params = lv.getLayoutParams();
params.height = lv/2; //Set to half the screens size
this.lv.setLayoutParams(params);
this.lv.invalidate();
}
}