次のコードスニペットが期待どおりに機能しない理由を誰かに説明してもらえますか?最初のテキストビューにパラメータを使用することはできません。使用する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>