I have a ListView and a button in my view. Button is placed just below the listview. My listview contains 10 items. When I am running the application. I can't see the button inside the view. Because of 10 items i have to scroll the listview to see all items. If i use 4 items, I can see the button. Why it is happened? Please help me. Thank you..
Sounds like you might not use layout correctly. Are you using a linear layout in the view? If so you might want to look at relative layout. Align your button to parentBottom and make you list align to parentTop and to above your button. That should make the list scroll and not expand.
I think you want button to be displayed always on the screen whatever maybe the size of the screen/list. Just make your layouts to be AbsoluteLayouts as below
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pixels"
android:layout_y="50px"
android:layout_x="80px"
android:focusable="true">
</Button>
<ListView android:id="@+id/ListView01"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
</ListView>
</AbsoluteLayout>
& in you UI thread use bringToFront on that button as below
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
Button b= (Button) findViewById(R.id.button);
b.setText("Button");
b.bringToFront();
....
}
and you are done!
Sorry friends... I did not get the correct answer when I using these solutions. But I solved thei problem by setting a fixed height for ListView (200px). Anyway thank you friends for these valuable informations...
But I suddenly faced another problem. When I am scrolling down the ListView, if its focus go beyond the last element, My application is suddenly stopped. Why this is happened? Please help me...