Android layouting with Relative Layout -



Android layouting with Relative Layout -

could please explain me why next snippet of code doesn't work expected? cannot utilize android:layout_alignparentbottom="true" param first text view because doing set view @ bottom of whole screen.

<?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 bottom of 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 previous text view"/> </relativelayout>

eclipse says @id/bottom_text_view couldn't resolved.

please take in business relationship illustration simplification of real case want set more complex views on top of button i.e. collapsible list view , calendar in next order:

listview calendar button

and need collapse both listview , calendar , 1 time done remains visible should move in order wrap content.

please help stuff.

thanks in advance.

edit: below there real case layout list view didn't take space want take.

<?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"/> <!-- utilize linear layout in order command margins in 1 place --> <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"> <!-- header asset info --> <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"> <!-- generate study 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 study button layout --> <!-- filter 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 filter date switch command --> <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> <!-- section 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 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 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 date section layout --> <!-- filter 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 filter project switch command --> <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> <!-- 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>

its because setting height of relativelayout wrap_content re-create code after alter bit , see how work

<?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="match_parent" > <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 bottom of 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 previous text view"/> </relativelayout>

android layout relativelayout

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -