我在Android 1.5的RelativeLayout中遇到了视图重叠的问题...一切在Android 1.6和更高版本上都很正常。
我知道Android 1.5在RelativeLayout方面存在一些问题,但是我没有在StackOverflow或android beginners组中找到与我的具体问题相关的内容。
我的布局由四个部分组成,每个部分都由一个TextView、一个Gallery和另一个垂直对齐的TextView组成:
正在运行的应用程序
最近使用的应用程序
服务
进程
当这四组项目都显示时,一切正常。然而,我的应用程序允许用户指定某些项目不显示。如果用户关闭“正在运行的应用程序”、“最近使用的应用程序”或“服务”,那么剩余的部分就突然重叠在一起。
这是我的布局代码。我不确定自己做错了什么。当用户关闭一个部分的显示时,我使用了View.GONE可见性设置:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:layout_gravity="center_vertical"
android:background="@null"
>
<!-- Running Gallery View Items -->
<TextView
style="@style/TitleText"
android:id="@+id/running_gallery_title_text_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="1sp"
android:paddingRight="10sp"
android:text="@string/running_title"
/>
<Gallery
android:id="@+id/running_gallery_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/running_gallery_title_text_id"
android:spacing="5sp"
android:clipChildren="false"
android:clipToPadding="false"
android:unselectedAlpha=".5"
/>
<TextView
style="@style/SubTitleText"
android:id="@+id/running_gallery_current_text_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/running_gallery_id"
android:gravity="center_horizontal"
/>
<!-- Recent Gallery View Items -->
<TextView
style="@style/TitleText"
android:id="@+id/recent_gallery_title_text_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/running_gallery_current_text_id"
android:gravity="left"
android:paddingLeft="1sp"
android:paddingRight="10sp"
android:text="@string/recent_title"
/>
<Gallery
android:id="@+id/recent_gallery_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/recent_gallery_title_text_id"
android:spacing="5sp"
android:clipChildren="false"
android:clipToPadding="false"
android:unselectedAlpha=".5"
/>
<TextView
style="@style/SubTitleText"
android:id="@+id/recent_gallery_current_text_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/recent_gallery_id"
android:gravity="center_horizontal"
/>
<!-- Service Gallery View Items -->
<TextView
style="@style/TitleText"
android:id="@+id/service_gallery_title_text_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/recent_gallery_current_text_id"
android:gravity="left"
android:paddingLeft="1sp"
android:paddingRight="10sp"
android:text="@string/service_title"
/>
<Gallery
android:id="@+id/service_gallery_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/service_gallery_title_text_id"
android:spacing="5sp"
android:clipChildren="false"
android:clipToPadding="false"
android:unselectedAlpha=".5"
/>
<TextView
style="@style/SubTitleText"
android:id="@+id/service_gallery_current_text_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/service_gallery_id"
android:gravity="center_horizontal"
/>
</RelativeLayout>
我删掉了进程部分的xml,试图让这篇文章更简短一些...
我该怎么做才能让它在Android 1.5上运行?我认为这不仅仅是重新排列xml中的视图,因为当所有内容都显示时它可以正常工作。