我目前正在开发一个Android应用程序,并且我有一个关于布局的问题。在我的XML布局文件中,我创建了一个相对布局(fill_parent的宽度和wrap_content的高度),其中包含一个列表视图(或可能是一个消耗性的列表视图 - fill_parent高度和宽度)。在相应的activity的onCreate方法中,我只需将对应于我的列表的适配器设置并将其附加到我的列表中。问题是,当我运行我的应用程序相对布局只有93dip的大小,所以它隐藏我的列表,其大小从67到210dip当我想相对布局高度坚持列表当前大小(大小在创建或恢复活动时可能不会通过活动中的操作进行更改)。有谁会有解决方案的想法来解决这个问题吗?设置包含listView的相对布局的高度
因为问了一些代码:
<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>
并在Java文件(其中snapRecords是我的对象列表):
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);
提前感谢您的帮助!
贝尼亚
你可以添加的布局和一些代码吗? –
你为什么不使用LinearLayout?在你的项目中使用RelativeLayout有什么特别的理由吗? – Jayabal
那么,理论上我可以修改它,但我宁愿不这样做,因为那意味着对我来说会有很多变化,但对于其他从事项目工作的人也是如此......如果我真的需要,但我首先想要知道如果解决方案可能存在与我的问题相对布局... – Ben