我正在试图制作一个文件管理器应用程序,其中我列出了屏幕上半部分ListFragment中某个目录的内容(不用说这个列表可以滚动),当用户点击某个文件/文件夹时,与它关联的元数据应该在放在片段正下方的FrameLayout中可见,以及文件类型的缩略图。这是我的布局:如何使一个ListFragment仅占用屏幕的上半部分
<?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:background="#00000000">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.4" >
<fragment
android:id="@+id/titles"
android:layout_width="match_parent"
android:layout_height="wrap_content"
class="com.test.fileManager.FileManagerActivity$TitlesFragment"
/>
</ScrollView>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:background="#00000000"
>
</FrameLayout>
</LinearLayout>
我用“layout_weight”属性首先没有了滚动标签,但那些重性只是没有被碎片尊重和列表远远高达屏幕的底部。
当我把ScrollView标签中的片段(我知道..不是一个好主意!),我一次只能看到列表中的一个条目。
无论如何,我可以让ListFragment占据屏幕的前40%,并在必要时在40%的屏幕空间中显示可滚动列表?
这就像一个魅力!我知道在ScrollView中嵌入一个可滚动的实体是一个坏主意。我没有太在意高度参数,因为我认为无论如何,当他们指定重量属性时(垂直方向),它们被UI框架忽略了,但这绝对不是这种情况。非常感谢! – HungryTux 2012-03-20 12:30:54
@HungryTux:如果它帮助你,你可能会想要答案:) – Namratha 2013-01-24 09:09:12