The items in RecyclerView fit the width space irregularly - android

I have a RecycleView that loads review comments in a vertical LinearLayout that has layout_width attribute set to "match_parent". The adapter loads the items, but not as expected.
The first few items in my adapter do not fit the entire width space and they look visually wrong. But as I scroll down the list, it looks like the list refreshes itself and now the items are loaded fitting the entire width space.
I do not know how to best describe this problem as I have not found anything relevant concerning it. What do you think it is and how can I fix visually my RecyclerView?
enter image description here
enter image description here
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="#2A2A2A">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/poster_image"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_width="150dp"
android:layout_height="230dp" />
<LinearLayout
android:layout_marginTop="40dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/release_date_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="24sp"
android:textStyle="italic"
android:textColor="#color/white"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/first_star"
android:backgroundTint="#color/colorAccent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_grade_white_18px"/>
<ImageView
android:id="#+id/second_star"
android:backgroundTint="#color/colorAccent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_grade_white_18px"/>
<ImageView
android:id="#+id/third_star"
android:backgroundTint="#color/colorAccent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_grade_white_18px"/>
<ImageView
android:id="#+id/forth_star"
android:backgroundTint="#color/colorAccent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_grade_white_18px"/>
<ImageView
android:id="#+id/fifth_star"
android:backgroundTint="#color/colorAccent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_grade_white_18px"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp">
<TextView
android:id="#+id/vote_average_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="22sp"
android:textColor="#color/white"
/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#EEFF41"
android:text="ADD"
android:textSize="18sp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginBottom="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="24sp"
android:textColor="#color/white"
android:text="Overview" />
<View
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_width="match_parent"
android:layout_height="3dp"
android:background="#FF6F00" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/overview_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textColor="#color/white"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="30dp"
android:layout_marginBottom="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="24sp"
android:textColor="#color/white"
android:text="Reviews"/>
<View
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_width="match_parent"
android:layout_height="3dp"
android:background="#FF6F00" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:id="#+id/review_fragment_head"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginBottom="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="24sp"
android:textColor="#color/white"
android:text="Trailers"/>
<View
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_width="match_parent"
android:layout_height="3dp"
android:background="#FF6F00" />
</LinearLayout>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
</ScrollView>

Related

Recyclerview items text look different on different devices

I am working on an activity that has three recyclerviews.
My issue is that the output is different on different devices.
I am testing the app on my real device and on the Android Studio emulators, and the output is right. But I have some customers users who say that the output is wrong.
Here is my screen shot with the right output:
And this is the wrong output on some devices:
I have tried changing text size, but with no success.
I ask you where should I start looking for a solution, at recyclerview or at item view?
EDIT
Activity Layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f2f2f2">
<LinearLayout
android:id="#+id/cabeceraTicket"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/cardview_dark_background"
android:orientation="horizontal">
<TextView
android:id="#+id/txtTicket"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="1"
android:text="Ticket: "
android:textColor="#color/cardview_light_background"
android:textSize="18sp" />
<TextView
android:id="#+id/txtSalon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="1"
android:text="Salón: "
android:textColor="#color/cardview_light_background"
android:textSize="18sp" />
<TextView
android:id="#+id/txtMesa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="1"
android:text="Mesa:"
android:textColor="#color/cardview_light_background"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/botones"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/cabeceraTicket"
android:orientation="horizontal">
<Button
android:id="#+id/btnTodo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Menu/Ticket" />
<Button
android:id="#+id/btnMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Menu" />
<Button
android:id="#+id/btnTicket"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Ticket" />
</LinearLayout>
<LinearLayout
android:id="#+id/botones2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/botones"
android:layout_weight="1"
android:orientation="horizontal">
<Button
android:id="#+id/btnRegresar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#009688"
android:text="Salir"
android:textColor="#color/white" />
<Button
android:id="#+id/btnMarchar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#3F51B5"
android:text="Marchar todo"
android:textColor="#color/white" />
</LinearLayout>
<Button
android:id="#+id/btnConectar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:visibility="gone" />
<LinearLayout
android:id="#+id/menus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/botones2"
android:orientation="vertical">
<TextView
android:id="#+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Menú"
android:textSize="24sp"
android:textStyle="bold" />
<LinearLayout
android:id="#+id/lmenu1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/l0"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:src="#android:drawable/ic_media_previous" />
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerViewMenu0"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="10"
android:orientation="horizontal">
</android.support.v7.widget.RecyclerView>
<ImageView
android:id="#+id/r0"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:src="#android:drawable/ic_media_next" />
</LinearLayout>
<LinearLayout
android:id="#+id/lmenu2"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:visibility="visible">
<ImageView
android:id="#+id/l1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:src="#android:drawable/ic_media_previous" />
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerViewMenu1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="10"
android:orientation="horizontal">
</android.support.v7.widget.RecyclerView>
<ImageView
android:id="#+id/r1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:src="#android:drawable/ic_media_next" />
</LinearLayout>
<LinearLayout
android:id="#+id/lmenu3"
android:layout_width="match_parent"
android:layout_height="80dp"
android:orientation="horizontal"
android:visibility="visible">
<ImageView
android:id="#+id/l2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:src="#android:drawable/ic_media_previous" />
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerViewArticulos1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="10"
android:orientation="horizontal">
</android.support.v7.widget.RecyclerView>
<ImageView
android:id="#+id/r2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:src="#android:drawable/ic_media_next" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/ticket"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/menus"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/titulo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/textView4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Ticket"
android:textSize="24sp"
android:textStyle="bold" />
<ListView
android:id="#+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/titulo"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:listSelector="#drawable/list_selector"
android:state_activated="true" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
First recyclerview item layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_margin="1dp">
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
app:cardCornerRadius="4dp"
app:cardElevation="1dp"
app:cardMaxElevation="2dp">
<RelativeLayout
android:id="#+id/relative"
android:layout_width="120dp"
android:layout_height="50dp"
android:gravity="center_horizontal|center_vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:layout_weight="4"
android:autoSizeMaxTextSize="15sp"
android:autoSizeMinTextSize="8sp"
android:autoSizeTextType="uniform"
android:gravity="center|center_horizontal|center_vertical"
android:padding="12dp"
android:text="Canada"
android:textAllCaps="false"
android:textColor="#color/red_A700"
android:textSize="30sp"
android:textStyle="bold"
app:autoSizeMinTextSize="20sp"
app:fontFamily="sans-serif" />
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
Second recyclerview item layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_margin="1dp">
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
app:cardCornerRadius="4dp"
app:cardElevation="1dp"
app:cardMaxElevation="2dp">
<RelativeLayout
android:id="#+id/relative"
android:layout_width="120dp"
android:layout_height="50dp"
android:gravity="center_horizontal|center_vertical">
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:autoSizeMaxTextSize="15sp"
android:autoSizeMinTextSize="8sp"
android:autoSizeTextType="uniform"
android:gravity="center|center_horizontal|center_vertical"
android:padding="12dp"
android:text="Canada"
android:textAllCaps="false"
android:textColor="#color/red_A700"
android:textSize="30sp"
android:textStyle="bold"
app:autoSizeMinTextSize="20sp"
app:fontFamily="sans-serif" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
Third recyclerview item layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_margin="1dp">
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
app:cardCornerRadius="4dp"
app:cardElevation="1dp"
app:cardMaxElevation="2dp">
<RelativeLayout
android:id="#+id/relative"
android:layout_width="120dp"
android:layout_height="50dp"
android:gravity="center_horizontal|center_vertical">
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:autoSizeMaxTextSize="15sp"
android:autoSizeMinTextSize="8sp"
android:autoSizeTextType="uniform"
android:gravity="center|center_horizontal|center_vertical"
android:padding="12dp"
android:text="Canada"
android:textAllCaps="false"
android:textColor="#color/red_A700"
android:textSize="30sp"
android:textStyle="bold"
app:autoSizeMinTextSize="20sp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
your code contain like this,
<RelativeLayout
android:id="#+id/relative"
android:layout_width="120dp"
android:layout_height="50dp"
android:gravity="center_horizontal|center_vertical"></>
you need to change the item layout fixed length width
I would suggest not to set values for the textsize in your xml at all (either in dp or sp). Let each user choose their preferred textSize by changing the system-wide font size in the device's Settings--->Display--->FontSize.
Just make sure any container for these textViews (the parent layout of each textView) can accommodate textViews of varying sizes. One way this can be accomplished, is by setting the container's width and height values to 'WrapContent' if possible.
My answer should be viewed like a shift in your approach to text sizes in general, rather than a specific answer to a specific problem like the one you are facing. There may well be easier and faster solutions if you just want to quick-fix your current issue.

Two LinearLayouts side by side, one with minimum-width

I got a RelativeLayout and inside there are two LinearLayouts side by side. Now I want that the right one has a minimum width of 125dp. So when the left LinearLayout gets too big, it should stop before the other LinearLayout and not push that one away.
How can I achieve this? This is my current approach:
Layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/item_list_item"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp">
<ImageButton
android:id="#+id/basket_item_list_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#android:color/transparent"
android:minWidth="50dp"
android:minHeight="50dp"
app:srcCompat="#drawable/ic_garbage"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_toRightOf="#+id/basket_item_list_delete"
android:layout_toEndOf="#+id/basket_item_list_delete">
<LinearLayout
android:id="#+id/basket_item_list_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:orientation="vertical">
<TextView
android:id="#+id/basket_item_list_itemname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:text="ItemName"
android:textColor="#color/generalText"
android:textSize="18sp" />
<TextView
android:id="#+id/basket_item_list_options"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:text="Options"/>
</LinearLayout>
<LinearLayout
android:id="#+id/priceLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="125dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:orientation="vertical"
android:layout_toRightOf="#id/basket_item_list_description">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="#+id/basket_item_list_increment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/basket_item_list_count"
android:layout_toStartOf="#+id/basket_item_list_count"
android:minWidth="45dp"
android:minHeight="45dp"
android:text="+"
android:textSize="20sp"
android:textColor="#color/colorPrimary"
android:background="#android:color/transparent" />
<TextView
android:id="#+id/basket_item_list_count"
android:layout_width="35dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="false"
android:layout_alignParentRight="false"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/basket_item_list_decrement"
android:layout_toStartOf="#+id/basket_item_list_decrement"
android:gravity="center_horizontal"
android:text="nx"
android:textColor="#color/generalText"
android:textSize="14sp" />
<Button
android:id="#+id/basket_item_list_decrement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:minWidth="45dp"
android:minHeight="45dp"
android:text="–"
android:textSize="20sp"
android:textColor="#color/colorPrimary"
android:background="#android:color/transparent" />
</RelativeLayout>
<TextView
android:id="#+id/basket_item_list_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="50dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:text="1€"
android:gravity="right"
android:layout_gravity="right"
android:textColor="#color/generalText"
android:textSize="14sp" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
I want to have it like this:
But this is what happens, when the left LinearLayout gets too big:
Try this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/item_list_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">
<ImageButton
android:id="#+id/basket_item_list_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:background="#android:color/transparent"
android:minHeight="50dp"
android:minWidth="50dp"
app:srcCompat="#drawable/ic_menu_gallery" />
<LinearLayout
android:id="#+id/basket_item_list_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingTop="10dp">
<TextView
android:id="#+id/basket_item_list_itemname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:text="ItemName"
android:textColor="#color/colorPrimary"
android:textSize="18sp" />
<TextView
android:id="#+id/basket_item_list_options"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:text="Options" />
</LinearLayout>
<LinearLayout
android:id="#+id/priceLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:gravity="right"
android:minWidth="125dp"
android:orientation="vertical"
android:paddingBottom="10dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">
<Button
android:id="#+id/basket_item_list_increment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:minHeight="45dp"
android:minWidth="45dp"
android:text="+"
android:textColor="#color/colorPrimary"
android:textSize="20sp" />
<TextView
android:id="#+id/basket_item_list_count"
android:layout_width="35dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="nx"
android:textColor="#color/colorPrimary"
android:textSize="14sp" />
<Button
android:id="#+id/basket_item_list_decrement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:minHeight="45dp"
android:minWidth="45dp"
android:text="–"
android:textColor="#color/colorPrimary"
android:textSize="20sp" />
</LinearLayout>
<TextView
android:id="#+id/basket_item_list_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:gravity="center"
android:minWidth="50dp"
android:text="1€"
android:textColor="#color/colorPrimary"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
Let try this ,
It will divide a screen Half and Half.
<LinearLayout
android:id="#+id/priceLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/priceLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".5"
android:orientation="vertical">
///Your views
</LinearLayout>
<LinearLayout
android:id="#+id/priceLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".5"
android:orientation="vertical">
///Your views
</LinearLayout>
</LinearLayout>
If You want first Wrap another one take remaining width take this
<LinearLayout
android:id="#+id/priceLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/priceLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
///Your views
</LinearLayout>
<LinearLayout
android:id="#+id/priceLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
///Your views
</LinearLayout>
</LinearLayout>

When TextView expanded below linerview is disappear

I have a problem when my TextView expanded with many texts the items below the TextView is disappeared.
I am talking about the TextView with ID: tvPostBody
I added ScrolleView to make sure the text will display completely if the text is more than max lines of TextView
Here is my XML file code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
tools:context="com.atjt.login.DisplayOnePost">
<LinearLayout
android:layout_width="368dp"
android:layout_height="495dp"
android:orientation="vertical"
tools:layout_editor_absoluteX="3dp"
tools:layout_editor_absoluteY="-2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/ivUserImage"
android:layout_width="108dp"
android:layout_height="127dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginBottom="5dp"
android:layout_weight="0.13"
android:cropToPadding="true"
android:padding="1dp"
android:scaleType="centerCrop"
app:srcCompat="#mipmap/no_image" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/tvUserFullName"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="User Full Name"
android:textAlignment="viewEnd" />
<TextView
android:id="#+id/tvPostTitle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:lineSpacingExtra="8sp"
android:text="Post Title in Full"
android:textColor="#android:color/background_dark"
android:textDirection="rtl"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ScrollView
android:id="#+id/SCROLLER_ID"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:fillViewport="true">
<TextView
android:id="#+id/tvPostBody"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:text="TextView" />
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginRight="10dp"
android:orientation="horizontal">
<TextView
android:id="#+id/tvNumberOfReplies"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:text="0" />
<TextView
android:id="#+id/tvReply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Reply" />
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="|" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/tvNumberOfViews"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:text="0" />
<TextView
android:id="#+id/tvViews"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Views" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/tvDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="105dp"
android:layout_weight="1"
android:text="15-12-2017" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
Any suggestions,
Problem is
<ScrollView
android:id="#+id/SCROLLER_ID"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:fillViewport="true">
Here, height is specified as wrap_content and therefore, it may fill entire below area and view below it may not be visible.
You need to specify some height for this so that you views below it are always visible.

Recycle view row text overlaps on smaller devices

I am building a simple row layout to add data dynamicly inside my recycle view, so i builded a a layout like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#cfcfcf">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:background="#ffffff"
android:orientation="horizontal">
<ImageView
android:id="#+id/plantPhoto"
android:layout_width="120dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#c7c7c7"
android:padding="0dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="20"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.example.afcosta.inesctec.pt.android.Helpers.NexusBoldTextView
android:id="#+id/plantName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:padding="15dp"
android:text="TextView"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/emerald" />
<ImageView
android:id="#+id/starIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:padding="15dp"
android:src="#drawable/ic_star" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="15dp">
<com.example.afcosta.inesctec.pt.android.Helpers.NexusBoldTextView
android:id="#+id/data"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toStartOf="#+id/cameraForbiden"
android:text="TextView"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/base" />
<ImageView
android:id="#+id/cameraForbiden"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:src="#drawable/ic_no_photos" />
<ImageView
android:id="#+id/userIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:src="#drawable/ic_user" />
<com.example.afcosta.inesctec.pt.android.Helpers.NexusBoldTextView
android:id="#+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/userIcon"
android:layout_alignBottom="#+id/userIcon"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Filipe"
android:textColor="#color/base" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
the main problem on this approach is that when i check my solution on smaller devices the text at left orverlaps the text at right, one solution that i am searching is to decrease the content based on the device size, but didn't find that yet.
This is what i get on a Nexus 5 for example:
this is what i get on a smaller device:
any help with this guys?
Thank you very much
You can use Linear layout for this. You can assign weight to each item.
Try this code :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#cfcfcf">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:background="#ffffff"
android:orientation="horizontal">
<ImageView
android:id="#+id/plantPhoto"
android:layout_width="120dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#c7c7c7"
android:padding="0dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="20"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/plantName"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="left"
android:padding="15dp"
android:text="TextView"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/black" />
<ImageView
android:id="#+id/starIcon"
android:layout_width="0dp"
android:layout_weight="0.5"
android:layout_height="wrap_content"
android:padding="15dp"
android:src="#drawable/ic_art_track_black_24dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="15dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/cameraForbiden"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:src="#drawable/ic_art_track_black_24dp" />
<TextView
android:id="#+id/data"
android:layout_width="0dp"
android:layout_weight="2.5"
android:layout_height="wrap_content"
android:text="TextView"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/black" />
<TextView
android:id="#+id/password"
android:layout_width="0dp"
android:layout_weight="2"
android:textAlignment="viewEnd"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/userIcon"
android:layout_alignBottom="#+id/userIcon"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Filipe"
android:textColor="#color/black" />
<ImageView
android:id="#+id/userIcon"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:gravity="left"
android:src="#drawable/ic_art_track_black_24dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>

The layout in red color Layout is not visible over the silver one

The layout in red color Layout is not visible over the silver one. I would like to overlap the container and make visible the textview visible in above container.
Please suggest what should be the solution as marginTop=-30dp seems to work bad. Any help would be appriciated.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="400dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#676363"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:text="#string/special_offer"
android:id="#+id/special_offer"
android:textStyle="bold"
android:textSize="25dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textColor="#f0eaea" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:text="#string/disney_less"
android:id="#+id/disney_less"
android:textStyle="bold"
android:textSize="20dp"
android:layout_below="#+id/special_offer"
android:layout_centerHorizontal="true"
android:textColor="#ef6e6e"
android:shadowColor="#ffffff" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/choose_disney"
android:id="#+id/choose_disney"
android:textSize="15dp"
android:textColor="#eef7e3"
android:textStyle="bold"
android:layout_below="#+id/disney_less"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/take_advantage"
android:id="#+id/take_advantage"
android:layout_gravity="center_horizontal"
android:textColor="#191717"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="false"
android:paddingStart="10dp"
android:paddingEnd="5dp"
android:gravity="bottom"
android:layout_alignParentEnd="false" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="vertical"
android:background="#efefef"
>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="#string/disney_world"
android:id="#+id/disney_world"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:textStyle="bold"
android:textSize="30dp"
android:fontFamily="#string/common_google_play_services_enable_text"
android:textColor="#0b125f" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="400dp"
android:orientation="vertical"
android:background="#efefef"
>
<RelativeLayout
android:layout_height="320dp"
android:layout_width="match_parent">
<FrameLayout android:layout_height="160dp"
android:layout_width="match_parent"
android:background="#a9a9a9"
>
</FrameLayout>
<LinearLayout
android:layout_height="160dp"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_marginTop="160dp"
android:background="#e4e4e4"
>
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="#a26262"
android:layout_marginTop="-30dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/save_upto"
android:id="#+id/save_upto"
android:textStyle="bold"
android:textColor="#1c234a"
android:textSize="20dp"
android:layout_gravity="center"
android:layout_marginTop="5dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/room_selected"
android:text="#string/room_selected"
android:textSize="12dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_gravity="center"
android:layout_marginBottom="7dp"
android:layout_marginTop="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/great_rate"
android:text="#string/great_rate"
android:textSize="12dp"
android:paddingLeft="35dp"
android:paddingRight="35dp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<LinearLayout android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="#a3d5d1ef"
android:backgroundTintMode="screen"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/more_information"
android:id="#+id/more_information"
android:textColor="#1c234a"
android:textSize="16dp"
android:layout_marginTop="5dp"
android:layout_gravity="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/special_saving"
android:id="#+id/special_saving"
android:textColor="#040404"
android:textSize="16dp"
android:textStyle="bold"
android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_marginBottom="5dp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
So I went ahead and tried to view your code by putting it in Android Studio and I got this:
The red layout is under the silver layout, which makes the save up to textview not visible. And by your description -- I would like to overlap the container and make visible the textview visible in above container. -- you want the layout with silver background to be on top of the red layout, where it shows the TextView with Save Up to, and if what I imagine it would like is correct, it would be something like this:
Here is the modified code:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="400dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#676363">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp">
<TextView
android:id="#+id/special_offer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:text="Special Offer"
android:textColor="#f0eaea"
android:textSize="25dp"
android:textStyle="bold" />
<TextView
android:id="#+id/disney_less"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/special_offer"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:shadowColor="#ffffff"
android:text="Disney Less"
android:textColor="#ef6e6e"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="#+id/choose_disney"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/disney_less"
android:layout_centerHorizontal="true"
android:text="Choose Disney"
android:textColor="#eef7e3"
android:textSize="15dp"
android:textStyle="bold" />
<TextView
android:id="#+id/take_advantage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="false"
android:layout_alignParentLeft="false"
android:layout_alignParentRight="false"
android:layout_gravity="center_horizontal"
android:gravity="bottom"
android:paddingEnd="5dp"
android:paddingLeft="10dp"
android:paddingRight="5dp"
android:paddingStart="10dp"
android:text="Take Advantage"
android:textColor="#191717" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#efefef"
android:orientation="vertical"
>
<TextView
android:id="#+id/disney_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:text="Disney World"
android:textColor="#0b125f"
android:textSize="30dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="400dp"
android:background="#efefef"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="320dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="160dp"
android:background="#a9a9a9" />
<!--<LinearLayout-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="160dp"-->
<!--android:layout_marginTop="160dp"-->
<!--android:background="#e4e4e4"-->
<!--android:orientation="vertical">-->
<!--</LinearLayout>-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="30dp"
android:background="#a26262"
android:orientation="vertical">
<TextView
android:id="#+id/save_upto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:text="Save Up to"
android:textColor="#1c234a"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="#+id/room_selected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="7dp"
android:layout_marginTop="5dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="Room Selected"
android:textSize="12dp" />
<TextView
android:id="#+id/great_rate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="35dp"
android:paddingRight="35dp"
android:text="Great Rate"
android:textSize="12dp" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#a3d5d1ef"
android:backgroundTintMode="screen"
android:orientation="vertical">
<TextView
android:id="#+id/more_information"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:text="More Info"
android:textColor="#1c234a"
android:textSize="16dp" />
<TextView
android:id="#+id/special_saving"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:text="Special Saving"
android:textColor="#040404"
android:textSize="16dp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
Hope this helps, if ever this is not the full answer you are looking for, feel free to comment and I'll try to help as much as I can. :)
Akshat try this
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="400dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#676363">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp">
<TextView
android:id="#+id/special_offer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:text="special_offer"
android:textColor="#f0eaea"
android:textSize="25dp"
android:textStyle="bold" />
<TextView
android:id="#+id/disney_less"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/special_offer"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:shadowColor="#ffffff"
android:text="disney_less"
android:textColor="#ef6e6e"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="#+id/choose_disney"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/disney_less"
android:layout_centerHorizontal="true"
android:text="choose_disney"
android:textColor="#eef7e3"
android:textSize="15dp"
android:textStyle="bold" />
<TextView
android:id="#+id/take_advantage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="false"
android:layout_alignParentLeft="false"
android:layout_gravity="center_horizontal"
android:gravity="bottom"
android:paddingEnd="5dp"
android:paddingStart="10dp"
android:text="ake_advantage"
android:textColor="#191717" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#efefef"
android:orientation="vertical"
>
<TextView
android:id="#+id/disney_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:text="asasdsa"
android:textColor="#0b125f"
android:textSize="30dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="400dp"
android:background="#efefef"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="320dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="160dp"
android:background="#a9a9a9">
</FrameLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_alignParentBottom="true"
android:background="#e4e4e4"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="#a26262"
android:orientation="vertical">
<TextView
android:id="#+id/save_upto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:text="ave_upto"
android:textColor="#1c234a"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="#+id/room_selected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="7dp"
android:layout_marginTop="5dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="room_selected"
android:textSize="12dp" />
<TextView
android:id="#+id/great_rate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="35dp"
android:paddingRight="35dp"
android:text="great_rate"
android:textSize="12dp" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#a3d5d1ef"
android:backgroundTintMode="screen"
android:orientation="vertical">
<TextView
android:id="#+id/more_information"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:text="safsadf"
android:textColor="#1c234a"
android:textSize="16dp" />
<TextView
android:id="#+id/special_saving"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:text="asdg"
android:textColor="#040404"
android:textSize="16dp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
Simply use RelativeLayout or FrameLayout. The last child view will overlay everything else.
FrameLayout is some kind of view stack. Made for special cases.
RelativeLayout is pretty powerful. You can define rules like View A has to align parent layout bottom, View B has to align A bottom to top, etc
As for your question.
In the LinearLayout that follows the FrameLayout remove the background attribute as its width is match_parent as it will cover the FrameLayout and also reduce the layout_marginTop to 130dp to get he desired effect of layout_marginTop=-30dp and remove the layout_marginTop=-30dp from the below LinearLayout.
which gives you the following
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="400dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#676363">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp">
<TextView
android:id="#+id/special_offer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:text="#string/special_offer"
android:textColor="#f0eaea"
android:textSize="25dp"
android:textStyle="bold" />
<TextView
android:id="#+id/disney_less"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/special_offer"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:shadowColor="#ffffff"
android:text="#string/disney_less"
android:textColor="#ef6e6e"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="#+id/choose_disney"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/disney_less"
android:layout_centerHorizontal="true"
android:text="#string/choose_disney"
android:textColor="#eef7e3"
android:textSize="15dp"
android:textStyle="bold" />
<TextView
android:id="#+id/take_advantage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="false"
android:layout_alignParentLeft="false"
android:layout_gravity="center_horizontal"
android:gravity="bottom"
android:paddingEnd="5dp"
android:paddingStart="10dp"
android:text="#string/take_advantage"
android:textColor="#191717" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#efefef"
android:orientation="vertical">
<TextView
android:id="#+id/disney_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:fontFamily="#string/common_google_play_services_enable_text"
android:text="#string/disney_world"
android:textColor="#0b125f"
android:textSize="30dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="400dp"
android:background="#efefef"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="320dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="160dp"
android:background="#a9a9a9">
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_marginTop="130dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="#a26262"
android:orientation="vertical">
<TextView
android:id="#+id/save_upto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:text="#string/save_upto"
android:textColor="#1c234a"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="#+id/room_selected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="7dp"
android:layout_marginTop="5dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="#string/room_selected"
android:textSize="12dp" />
<TextView
android:id="#+id/great_rate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="35dp"
android:paddingRight="35dp"
android:text="#string/great_rate"
android:textSize="12dp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#a3d5d1ef"
android:backgroundTintMode="screen"
android:orientation="vertical">
<TextView
android:id="#+id/more_information"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:text="#string/more_information"
android:textColor="#1c234a"
android:textSize="16dp" />
<TextView
android:id="#+id/special_saving"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:text="#string/special_saving"
android:textColor="#040404"
android:textSize="16dp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

Categories

Resources