有人可以解释一下为什么下面的代码片段不能按预期工作吗?我不能将android:layout_alignParentBottom="true"
参数用于第一个文本视图,因为这样做会将视图放在整个屏幕的底部。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/bottom_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/color_black"
android:text="AT THE BOTTOM OF THE LAYOUT"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/bottom_text_view"
android:textColor="@color/color_black"
android:text="ABOVE THE PREVIOUS TEXT VIEW"/>
</RelativeLayout>
Eclipse 说@id/bottom_text_view
无法解决。
请考虑到这个例子是一个真实案例的简化,我想在按钮顶部放置更复杂的视图,即按以下顺序的可折叠列表视图和日历:
- 列表显示
- 日历
- 按钮
我真的需要同时折叠列表视图和日历,一旦完成,仍然可见的内容应该移动以便换行。
请帮忙处理这些东西。
提前致谢。
编辑:下面是我的真实案例布局列表视图没有占用我想要的空间。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/magnet_bkg" >
<TextView
android:id="@+id/assets_header_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/view_padding"
android:gravity="center"
android:ellipsize="end"
android:lines="1"
android:maxLines="1"
android:singleLine="true"
android:text="@string/lbl_asset_manager_title"
android:textColor="@color/color_white"
android:textStyle="bold"
android:textSize="@dimen/top_title_text_size"
android:background="@drawable/dashboard_title_gradient_bg"
android:visibility="visible"/>
<!-- Use the linear layout in order to control the margins in
one place only -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/assets_list_margin_side"
android:layout_marginRight="@dimen/assets_list_margin_side"
android:layout_marginTop="@dimen/assets_list_margin_topbottom"
android:layout_marginBottom="@dimen/assets_list_margin_topbottom"
android:orientation="vertical">
<!-- The header with the asset information -->
<include
layout="@layout/activity_magnet_enterprise_company_assets_list_item"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/view_padding"
android:textColor="@color/color_white"
android:textSize="@dimen/sub_title_text_size"
android:text="@string/lbl_report_filter_section_title"
android:gravity="center"
android:singleLine="true"
android:ellipsize="end"
android:background="@color/color_title_bar"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/create_report_filter_bottom_margin"
android:gravity="bottom">
<!-- The generate report Button -->
<LinearLayout
android:id="@+id/create_report_btn_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/filter_by_date_section_layout"
android:background="@color/color_repoback_dark"
android:gravity="center"
android:padding="@dimen/view_padding">
<Button
style="@style/NormalButton"
android:onClick="onBtnCreateReportClick"
android:text="@string/lbl_button_create_report" />
</LinearLayout> <!-- end of generate report Button layout -->
<!-- The filter by date section -->
<LinearLayout
android:id="@+id/filter_by_date_section_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/filter_by_project_section_layout"
android:orientation="vertical">
<!-- Sub header with the filter by date switch control -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_subtitle_bar"
android:padding="@dimen/view_padding_large" >
<Switch
android:id="@+id/filter_by_date_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@id/filter_by_date_switch"
android:ellipsize="end"
android:gravity="left"
android:singleLine="true"
android:text="@string/lbl_report_filter_by_date"
android:textColor="@color/color_white"
android:textSize="@dimen/sub_title_text_size_small" />
</RelativeLayout>
<!-- The section for date selection -->
<LinearLayout
android:id="@+id/date_selection_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_repoback_dark"
android:baselineAligned="false"
android:orientation="horizontal"
android:padding="@dimen/view_padding" >
<!-- Layout FROM date -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="@dimen/view_padding"
android:text="@string/lbl_report_date_from"
android:textColor="@color/color_white"
android:textSize="@dimen/small_text_size"
android:textStyle="bold" />
<DatePicker
android:id="@+id/from_date_report"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:calendarViewShown="false"
android:padding="@dimen/view_padding" />
</LinearLayout>
<!-- Layout TO date -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="@dimen/view_padding"
android:text="@string/lbl_report_date_to"
android:textColor="@color/color_white"
android:textSize="@dimen/small_text_size"
android:textStyle="bold" />
<DatePicker
android:id="@+id/to_date_report"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:calendarViewShown="false"
android:padding="@dimen/view_padding" />
</LinearLayout>
</LinearLayout>
</LinearLayout> <!-- end of filter by date section layout -->
<!-- The filter by project section -->
<LinearLayout
android:id="@+id/filter_by_project_section_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Sub header with the filter by project switch control -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_subtitle_bar"
android:padding="@dimen/view_padding_large" >
<Switch
android:id="@+id/filter_by_project_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@id/filter_by_project_switch"
android:ellipsize="end"
android:gravity="left"
android:singleLine="true"
android:text="@string/lbl_report_filter_by_project"
android:textColor="@color/color_white"
android:textSize="@dimen/sub_title_text_size_small" />
</RelativeLayout>
<!-- The projects list view -->
<ListView
android:id="@+id/projects_listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_schedule_list_bg"
android:choiceMode="singleChoice"
android:divider="@color/color_lightgray"
android:dividerHeight="1dp" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>