I have been getting the above error for quite some time. Upon a lot of prodding around, I've come to the conclusion that its my xml itself which is causing this issue. I have commented ALL of my code in my java file and tried to load JUST THE LAYOUT. Even then the warning keeps popping up. I am herein attaching my xml file, hoping someone can shed some light on this. I would like to know what are the "heavy duty" work being performed which is causing my app to "skip frames".
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:clipToPadding="false"
android:id="#+id/coordinator"
android:background="#drawable/back_1"
tools:context="com.avantaritech.flipa.MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/first_bar">
<android.support.v7.widget.AppCompatImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_menu_white_24dp"
android:contentDescription="#string/overflow_home"
android:id="#+id/nav_button"/>
<android.support.v7.widget.AppCompatImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/fill"
android:layout_alignParentTop="true"
android:id="#+id/logo"
android:layout_centerHorizontal="true" />
<android.support.v7.widget.AppCompatImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/sync_green"
android:id="#+id/sync_button"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"/>
<View
android:layout_width="match_parent"
android:layout_height="#dimen/_1sdp"
android:layout_margin="#dimen/_5sdp"
android:background="#android:color/darker_gray"
android:layout_below="#+id/logo"
android:id="#+id/view" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/view"
android:id="#+id/mega_relative"
android:layout_alignEnd="#+id/view">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/viewpager_holder_first"
android:layout_alignParentStart="true"
android:layout_marginTop="#dimen/_10sdp"
android:layout_alignParentTop="true">
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_marginTop="#dimen/_1sdp"
android:id="#+id/viewpager_first"
android:layout_height="#dimen/_225sdp"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true">
</android.support.v4.view.ViewPager>
<me.relex.circleindicator.CircleIndicator
android:id="#+id/indicator"
android:layout_width="match_parent"
android:layout_height="#dimen/_25sdp"
android:layout_below="#+id/viewpager_first"/>
</RelativeLayout>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="#dimen/_110sdp"
android:layout_below="#+id/viewpager_holder_first"
android:scrollbars="none"
android:overScrollMode="always"
android:id="#+id/horizontalScrollView">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginTop="#dimen/_10sdp"
>
<FrameLayout
android:layout_width="#dimen/_100sdp"
android:layout_height="match_parent"
android:background="#color/textbox_home">
<ImageView
android:layout_width="#dimen/_30sdp"
android:layout_height="#dimen/_30sdp"
android:src="#drawable/hr"
android:id="#+id/hr_image_home"
android:layout_margin="#dimen/_5sdp"
android:layout_gravity="left|top" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Heart Rate"
android:fontFamily="sans-serif-light"
android:id="#+id/hr_text_home"
android:layout_marginStart="#dimen/_10sdp"
android:layout_marginTop="#dimen/_10sdp"
android:layout_gravity="end|top" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00"
android:id="#+id/home_hr"
android:textSize="35sp"
android:textStyle="bold"
android:layout_gravity="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BPM"
android:textColor="#color/skin_v1"
android:layout_marginTop="#dimen/_75sdp"
android:layout_marginBottom="#dimen/_5sdp"
android:layout_gravity="center_horizontal|bottom" />
</FrameLayout>
<FrameLayout
android:layout_width="#dimen/_100sdp"
android:layout_height="match_parent"
android:elevation="#dimen/_10sdp"
android:layout_marginStart="#dimen/_15sdp"
android:background="#color/textbox_home">
<ImageView
android:layout_width="#dimen/_30sdp"
android:layout_height="#dimen/_30sdp"
android:src="#drawable/steps"
android:id="#+id/steps_image_home"
android:layout_margin="#dimen/_5sdp"
android:layout_gravity="left|top" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00"
android:id="#+id/home_steps"
android:textSize="30sp"
android:textStyle="bold"
android:layout_gravity="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="STEPS"
android:textColor="#color/skin_v1"
android:layout_marginTop="#dimen/_75sdp"
android:layout_marginBottom="#dimen/_5sdp"
android:layout_gravity="center_horizontal|bottom" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Steps"
android:fontFamily="sans-serif-light"
android:id="#+id/steps_text_home"
android:layout_marginEnd="#dimen/_5sdp"
android:layout_marginStart="#dimen/_30sdp"
android:layout_marginTop="#dimen/_10sdp"
android:layout_gravity="center_horizontal|top" />
</FrameLayout>
<FrameLayout
android:layout_width="#dimen/_100sdp"
android:layout_height="match_parent"
android:elevation="#dimen/_10sdp"
android:layout_marginStart="#dimen/_25sdp"
android:background="#color/textbox_home">
<ImageView
android:layout_width="#dimen/_30sdp"
android:layout_height="#dimen/_30sdp"
android:src="#drawable/dist"
android:id="#+id/dist_image_home"
android:layout_margin="#dimen/_5sdp"
android:layout_gravity="left|top" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00"
android:id="#+id/dist_textview_home"
android:textSize="30sp"
android:textStyle="bold"
android:layout_gravity="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="METERS"
android:id="#+id/dist_unit"
android:textColor="#color/skin_v1"
android:layout_marginTop="#dimen/_75sdp"
android:layout_marginBottom="#dimen/_5sdp"
android:layout_gravity="center_horizontal|bottom" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Distance"
android:fontFamily="sans-serif-light"
android:id="#+id/dist_text_home"
android:layout_marginTop="#dimen/_10sdp"
android:layout_marginStart="#dimen/_15sdp"
android:layout_gravity="center_horizontal|top" />
</FrameLayout>
<FrameLayout
android:layout_width="#dimen/_100sdp"
android:layout_height="match_parent"
android:elevation="#dimen/_10sdp"
android:layout_marginStart="#dimen/_30sdp"
android:background="#color/textbox_home">
<ImageView
android:layout_width="#dimen/_30sdp"
android:layout_height="#dimen/_30sdp"
android:src="#drawable/pace"
android:id="#+id/pace_image_home"
android:layout_margin="#dimen/_5sdp"
android:layout_gravity="left|top" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00"
android:id="#+id/pace_textview_home"
android:textSize="30sp"
android:textStyle="bold"
android:layout_gravity="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="STEPS/MIN"
android:textColor="#color/skin_v1"
android:layout_marginTop="#dimen/_75sdp"
android:layout_marginBottom="#dimen/_5sdp"
android:layout_gravity="center_horizontal|bottom" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Avg. Pace"
android:fontFamily="sans-serif-light"
android:id="#+id/pace_text_home"
android:layout_marginTop="#dimen/_10sdp"
android:layout_marginStart="#dimen/_10sdp"
android:layout_gravity="center_horizontal|top" />
</FrameLayout>
<FrameLayout
android:layout_width="#dimen/_100sdp"
android:layout_height="match_parent"
android:elevation="#dimen/_10sdp"
android:layout_marginStart="#dimen/_30sdp"
android:background="#color/textbox_home">
<ImageView
android:layout_width="#dimen/_20sdp"
android:layout_height="#dimen/_20sdp"
android:src="#drawable/cal"
android:id="#+id/cal_avg_image_home"
android:layout_margin="#dimen/_5sdp"
android:layout_gravity="left|top" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00"
android:id="#+id/cal_avg_textview_home"
android:textSize="30sp"
android:textStyle="bold"
android:layout_gravity="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="KCAL/MIN"
android:textColor="#color/skin_v1"
android:layout_marginTop="#dimen/_75sdp"
android:layout_marginBottom="#dimen/_5sdp"
android:layout_gravity="center_horizontal|bottom" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Avg. KCAL"
android:fontFamily="sans-serif-light"
android:id="#+id/kcal_text_home"
android:layout_marginTop="#dimen/_10sdp"
android:layout_marginStart="#dimen/_10sdp"
android:layout_gravity="center_horizontal|top" />
</FrameLayout>
</LinearLayout>
</HorizontalScrollView>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="#+id/mega_relative"
android:layout_toEndOf="#+id/nav_button"
android:layout_alignParentStart="true">
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
app:fabSize="normal"
android:id="#+id/workout_start"
android:src="#drawable/run"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
Related
android.view.InflateException: Binary XML file line #44: ScrollView can host only one direct childCaused by: java.lang.IllegalStateException: ScrollView can host only one direct child at android.widget.ScrollView.addView(ScrollView.java:279)
atretrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:70)
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:aapt="http://schemas.android.com/aapt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/half_view_margin_standard"
android:layout_marginTop="#dimen/view_margin_standard"
android:layout_marginRight="#dimen/half_view_margin_standard"
android:layout_marginBottom="#dimen/half_view_margin_standard">
<LinearLayout
android:orientation="vertical"
android:id="#+id/ll_home_header_parent"
android:background="#color/card_background_color"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.core.widget.NestedScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<TextView
android:textSize="#dimen/app_titles_text_size"
android:textStyle="bold"
android:textColor="#color/abc_decor_view_status_guard"
android:gravity="center"
android:layout_gravity="center"
android:id="#+id/tv_month_name"
android:paddingTop="#dimen/view_margin_standard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="மே - திங்கள்"/>
<LinearLayout android:gravity="center" android:layout_gravity="center" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="#dimen/half_view_margin_standard">
<TextView android:textSize="#dimen/app_display_type_1_text_size"
android:textColor="#color/abc_decor_view_status_guard"
android:gravity="center"
android:layout_gravity="center"
android:id="#+id/tv_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="08-05-2017"
android:fontFamily="#font/product_bold"/>
</LinearLayout>
<LinearLayout
android:layout_width="335dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="#dimen/half_view_margin_standard"
android:layout_marginBottom="#dimen/half_view_margin_standard"
android:orientation="horizontal">
<TextView
android:id="#+id/sf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="#dimen/half_view_margin_standard"
android:gravity="left"
android:text="நல்ல நேரம்"
android:textColor="#color/black"
android:textSize="#dimen/app_body_type_1_text_size" />
<TextView
android:id="#+id/tv_morning"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="#dimen/half_view_margin_standard"
android:gravity="left"
android:text="கா"
android:textColor="#color/black"
android:textSize="#dimen/app_body_type_1_text_size" />
<TextView
android:id="#+id/tv_morning_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="#dimen/half_view_margin_standard"
android:gravity="left"
android:text="10.30 - 12.00"
android:textColor="#color/black"
android:textSize="#dimen/app_body_type_1_text_size" />
<TextView
android:id="#+id/tv_evening"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="#dimen/half_view_margin_standard"
android:text="மா"
android:textColor="#color/black"
android:textSize="#dimen/app_body_type_1_text_size" />
<TextView
android:id="#+id/tv_evening_time"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginLeft="#dimen/half_view_margin_standard"
android:gravity="left"
android:text="10.30 - 12.00"
android:textColor="#color/black"
android:textSize="#dimen/app_body_type_1_text_size" />
</LinearLayout><![CDATA[ 7.00 Maalai 4.30 - 6.00"/>
]]>
<LinearLayout
android:orientation="vertical"
android:background="#color/card_background_color"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/tv_tamil_month_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_gravity="center"
android:layout_marginLeft="#dimen/half_view_margin_standard"
android:gravity="center"
android:text="சித்திரைத்"
android:textColor="#color/abc_decor_view_status_guard"
android:textSize="#dimen/app_big_sub_heads_text_size" />
<TextView
android:id="#+id/tv_viratham_home"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_gravity="center"
android:layout_marginLeft="#dimen/half_view_margin_standard"
android:gravity="center"
android:text="சித்திரைத்"
android:textColor="#color/abc_decor_view_status_guard"
android:textSize="#dimen/app_big_sub_heads_text_size" />
<TextView
android:id="#+id/tv_viratham_time_range"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_gravity="center"
android:layout_marginLeft="#dimen/half_view_margin_standard"
android:gravity="center"
android:text="சித்திரைத்"
android:textColor="#color/abc_decor_view_status_guard"
android:textSize="#dimen/app_big_sub_heads_text_size" />
<TextView
android:textSize="#dimen/app_body_type_1_text_size"
android:textColor="#color/black"
android:gravity="center"
android:layout_gravity="center"
android:id="#+id/tv_vishesham"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/half_view_margin_standard"
android:text="காலை"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>
</androidx.cardview.widget.CardView>`
`
how to clear error this
you should use scrollview like this sample
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView />
<TextView />
<TextView />
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.core.widget.NestedScrollView>
Not Like this
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</androidx.appcompat.widget.LinearLayoutCompat>
<TextView />
<TextView />
<TextView />
</androidx.core.widget.NestedScrollView>
I want to have a layout exactly similar to one below in image.
I've tried the below code but it is not coming.
Can someone help me in getting this layout.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="6dip" >
<TextView
android:id="#+id/firstLine"
android:layout_width="fill_parent"
android:layout_height="26dip"
android:ellipsize="marquee"
android:singleLine="true"
android:text="Ali Connors"
android:textSize="12sp" />
<TextView
android:id="#+id/secondLine"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/firstLine"
android:gravity="center_vertical"
android:text="Brunch this weekend?"
android:textSize="16sp" />
<TextView
android:gravity="right"
android:id="#+id/rightTime"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="15m"
android:textSize="16sp" />
</RelativeLayout>
try the following:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="4dp"
android:background="#ED262A" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="6dp">
<TextView
android:id="#+id/firstLine"
android:layout_width="fill_parent"
android:layout_height="26dp"
android:layout_alignParentLeft="true"
android:layout_marginTop="5dp"
android:ellipsize="marquee"
android:singleLine="true"
android:text="Ali Connors"
android:textSize="18sp" />
<TextView
android:id="#+id/secondLine"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/firstLine"
android:gravity="center_vertical"
android:text="Brunch this weekend?"
android:textSize="15sp" />
<TextView
android:id="#+id/thirdLine"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/secondLine"
android:drawablePadding="6dp"
android:drawableRight="#android:drawable/star_off"
android:gravity="center_vertical"
android:text="I will be in the place"
android:textColor="#A4A18E"
android:textSize="14sp" />
<TextView
android:id="#+id/rightTime"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:layout_alignParentRight="true"
android:gravity="top|right"
android:text="15m"
android:textSize="16sp" />
</RelativeLayout>
</LinearLayout>
Try this.
<TextView
android:text="15m"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:id="#+id/rightTime"
android:textSize="16sp"/>
Design your Layout as below:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="4dp"
android:background="#FF4081" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<TextView
android:id="#+id/rightTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="15m"
android:textSize="14sp"
android:textColor="#727272"/>
<TextView
android:id="#+id/firstLine"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/rightTime"
android:layout_marginRight="8dp"
android:maxLines="1"
android:ellipsize="end"
android:text="Ali Connors"
android:textSize="16sp"
android:textColor="#000000"/>
<TextView
android:id="#+id/secondLine"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/firstLine"
android:layout_marginTop="2dp"
android:text="Brunch this weekend?"
android:textSize="16sp"
android:textColor="#000000"
android:maxLines="1"
android:ellipsize="end" />
<ImageView
android:id="#+id/image_star"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_below="#id/secondLine"
android:layout_alignParentRight="true"
android:background="#android:drawable/star_big_off" />
<TextView
android:id="#+id/thirdLine"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/secondLine"
android:layout_toLeftOf="#id/image_star"
android:layout_marginTop="4dp"
android:layout_marginRight="16dp"
android:text="I will be in your neighborhood doing some errands....."
android:textColor="#727272"
android:textSize="14sp"
android:maxLines="1"
android:ellipsize="end" />
</RelativeLayout>
</LinearLayout>
Output:
I've got a fragment from which users select features their rooms have (fig.1 below) and these are stored in the back-end as boolean values i.e. true if set and false otherwise.
The XML for the fragment:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
<!-- none core xml formatting and views -->
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="20dp"
android:weightSum="1"
android:layout_gravity="center_horizontal"
android:background="#drawable/border_bottom_top"
android:id="#+id/details_amenities_layout">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:baselineAligned="false">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingTop="5dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="38dp"
android:id="#+id/add_room_bic_imageview"
android:src="#mipmap/ic_bic"
android:padding="5dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/add_room_bic_amenity"
android:id="#+id/add_room_bic_label"
android:textSize="16sp"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_below="#+id/add_room_bic_imageview" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingTop="5dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="38dp"
android:id="#+id/add_room_entrance_imageview"
android:src="#mipmap/ic_entrance"
android:padding="5dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/add_room_entrance_amenity"
android:id="#+id/add_room_entrance_label"
android:textSize="16sp"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingTop="5dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="38dp"
android:id="#+id/add_room_toilet_imageview"
android:src="#mipmap/ic_toilet"
android:padding="5dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/add_room_toilet_amenity"
android:id="#+id/add_room_toilet_label"
android:textSize="16sp"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingTop="5dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="38dp"
android:id="#+id/add_room_kitchen_imageview"
android:src="#mipmap/ic_kitchen"
android:padding="5dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/add_room_kitchen_amenity"
android:id="#+id/add_room_kitchen_label"
android:textSize="16sp"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:baselineAligned="false"
android:layout_marginTop="8dp" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingTop="5dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="38dp"
android:id="#+id/add_room_parking_imageview"
android:src="#mipmap/ic_parking"
android:padding="5dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/add_room_parking_amenity"
android:id="#+id/add_room_parking_label"
android:textSize="16sp"
android:gravity="center"
android:layout_centerHorizontal="true"
android:layout_below="#+id/add_room_parking_imageview" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingTop="5dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="38dp"
android:id="#+id/add_room_wifi_imageview"
android:src="#mipmap/ic_wi_fi"
android:padding="5dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/add_room_wifi_amenity"
android:id="#+id/add_room_wifi_label"
android:textSize="16sp"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingTop="5dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="38dp"
android:id="#+id/add_room_secure_imageview"
android:src="#mipmap/ic_secure"
android:padding="5dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/add_room_secure_amenity"
android:id="#+id/add_room_secure_label"
android:textSize="16sp"
android:gravity="center"
android:layout_below="#+id/add_room_secure_imageview"
android:layout_centerHorizontal="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingTop="5dp" >
<ImageView
android:id="#+id/add_room_furnished_imageview"
android:src="#mipmap/ic_furnished"
style="#style/amenities_image_style"
android:layout_width="wrap_content"
android:layout_height="38dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/add_room_furnished_amenity"
android:id="#+id/add_room_furnished_label"
android:textSize="16sp"
android:gravity="center"
android:layout_below="#+id/add_room_furnished_imageview"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:baselineAligned="false"
android:layout_marginTop="5dp" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingTop="5dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="38dp"
android:id="#+id/add_room_borehole_imageview"
android:src="#mipmap/ic_borehole"
android:padding="5dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/add_room_borehole_amenity"
android:id="#+id/add_room_borehole_label"
android:textSize="16sp"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingTop="5dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="38dp"
android:id="#+id/add_room_prezesa_imageview"
android:src="#mipmap/ic_zesa"
android:padding="5dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/add_room_zesa_amenity"
android:id="#+id/add_room_prezesa_label"
android:textSize="16sp"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_alignEnd="#+id/add_room_prezesa_imageview"
android:layout_centerHorizontal="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingTop="5dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="38dp"
android:id="#+id/add_room_wardrobe_imageview"
android:src="#mipmap/ic_wardrobe"
android:padding="5dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/add_room_wardrobe_amenity"
android:id="#+id/add_room_wardrobe_label"
android:textSize="16sp"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingTop="5dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="38dp"
android:id="#+id/add_room_prewater_imageview"
android:src="#mipmap/ic_prewater"
android:padding="5dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/add_room_water_amenity"
android:id="#+id/add_room_prewater_label"
android:textSize="16sp"
android:gravity="center"
android:layout_below="#+id/add_room_prewater_imageview"
android:layout_alignRight="#+id/add_room_prewater_imageview"
android:layout_alignEnd="#+id/add_room_prewater_imageview"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<!-- none core views -->
<android.support.design.widget.FloatingActionButton android:id="#+id/add_room_step3_fab"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="end"
android:src="#mipmap/ic_done_white_48dp"
android:layout_marginBottom="#dimen/fab_margin" />
</LinearLayout>
</ScrollView>
Naturally the selected features differ thus the number of views is not constant obtained from the back-end. I am able to retrieve the set features and instantiate the correct views in Java i.e. if there are 5 set features comprising BIC, Wifi, Kitchen etc, I am able to determine these and set the necessary Image resources and Text.
Question now is how do I arrange the views obtained to replicate the layout above using Java code as I can only know the features set after querying the back-end. Desired end result has to look like the image below. Hope it makes sense.
This is the XML file for the main fragment that i am currently dealing with. the problem i am having is that when i clean the project it does not give me any errors but when i run the program the emulator crashes.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.budgetfuel.MainActivity$PlaceholderFragment" >
<LinearLayout
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="20dp" >
<TextView
android:id="#+id/textView3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Select Car:"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Spinner
android:id="#+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="20dp" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Price Per Litre:"
android:textAppearance="?android:attr/textAppearanceSmall" />
<EditText
android:id="#+id/editText1"
android:layout_width="171dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" />
</LinearLayout>
<Space
android:id="#+id/Space1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill_vertical" />
<LinearLayout
android:id="#+id/LinearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="20dp" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.66"
android:text="Litres:"
android:textAppearance="?android:attr/textAppearanceSmall" />
<EditText
android:id="#+id/editText2"
android:layout_width="171dp"
android:layout_height="wrap_content"
android:layout_weight="0.27"
android:ems="10" />
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="20dp" >
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="34dp"
android:layout_weight="0.80"
android:text="Odo Reading:"
android:textAppearance="?android:attr/textAppearanceSmall" />
<EditText
android:id="#+id/editText3"
android:layout_width="186dp"
android:layout_height="wrap_content"
android:layout_weight="0.40"
android:ems="10" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayout5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="20dp" >
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.20"
android:text="Date:"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Button
android:id="#+id/buttonDateSet"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:text="Change Date:" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:id="#+id/LinearLayout6"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/Output"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</LinearLayout>
Hoping this is a simple one.
I have a layout that uses a scrollview. This was fine until I wanted to put an image and textview above it then have the scrollview with my edittexts below it.
At the moment I'm getting the following errors:
01-22 20:13:32.228: E/AndroidRuntime(275): FATAL EXCEPTION: main
01-22 20:13:32.228: E/AndroidRuntime(275): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.flybase2/com.example.flybase2.addAppointment}: java.lang.RuntimeException: Binary XML file line #26: You must supply a layout_width attribute.
I have tried to change the scroll views width attribute (which i believe that error is pointing too) with no luck.
Here's my XML. Can anyone see what I'm doing wrong?:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="84dp"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imgLink"
android:layout_width="78dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="#drawable/viewcon" />
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="75dp"
android:gravity="center"
android:text="Appointments"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="35sp" />
</LinearLayout>
\\ERROR: On width attribute
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/inputAppName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Appointment Type:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner
android:id="#+id/spinner1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Appointment Time:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TimePicker
android:id="#+id/timePicker1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Appointment Time:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<DatePicker
android:id="#+id/datePicker1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Comments:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/inputAppCom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Set Appointment Date Alarm:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ToggleButton
android:id="#+id/toggleButton1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ToggleButton"
android:textOff="Alarm Off"
android:textOn="Alarm On" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add Appointment"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="#+id/btnAddAppointment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Add" />
</ScrollView>
</LinearLayout>
EDIT:
You can only set one child layout to a ScrollView. I don't know why it's showing you that you didn't set android:layout_width attribute, but your problem is definitely that you have multiple child views in your ScrollView.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="84dp"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imgLink"
android:layout_width="78dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="#drawable/viewcon" />
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="75dp"
android:gravity="center"
android:text="Appointments"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="35sp" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/inputAppName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Appointment Type:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner
android:id="#+id/spinner1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Appointment Time:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TimePicker
android:id="#+id/timePicker1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Appointment Time:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<DatePicker
android:id="#+id/datePicker1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Comments:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/inputAppCom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Set Appointment Date Alarm:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ToggleButton
android:id="#+id/toggleButton1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ToggleButton"
android:textOff="Alarm Off"
android:textOn="Alarm On" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add Appointment"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="#+id/btnAddAppointment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Add" />
</LinearLayout>
</ScrollView>
</LinearLayout>