I’m currently developing an Android app and I’ve got an issue concerning layout. In my XML layout file, I create a relative layout (fill_parent for width and wrap_content for height) which contains a list View (or possibly an expendable List View – fill_parent for height and width). In the corresponding activity onCreate method, I just set the adapter corresponding to my list and attach it to my list. The problem is that when I run my app the relative layout only has a size of 93dip and so it hides my list which has a size from 67 to 210dip when I would like the relative layout height to stick to the list current size (The size will never change through action in the activity just possibly when creating or resuming the activity). Would anyone have an idea of a solution to fix that ?
Some code as asked :
<LinearLayout android:id="@+id/content"
android:layout_width="fill_parent"
android:background="@drawable/row"
android:layout_below="@+id/header"
android:layout_height="wrap_content">
<ListView android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/listrow"/>
</LinearLayout>
And in the java file (where snapRecords is my object lists):
m_panel = (RelativeLayout)findViewById(R.id.lastFareRecordPanel);
ListView lv = (ListView)m_panel.findViewById(R.id.list);
final QuickSnapBookmarksAdapter adapter = new QuickSnapBookmarksAdapter(snapRecords, getApplicationContext(), this, lv);
lv.setAdapter(adapter);
Many thanks in advance for your help !
Benja
I had a similiar situation.When I changed parent layout into LinearLayout, it is working.Here is the code: