When TextView expanded below linerview is disappear - android

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.

Related

layout_below not working with layout_centerVertical

I have been trying to use RelativeLayout in ScrollView to positioning two LinearLayouts, one to top and one to center. I've used layout_alignParentTop and layout_centerVertical. To prevent overlapping I've tried to use layout_below on second LinearLayout but it breaks layout_centerVertical and the second LinearLayout goes to top. How to do it? Thanks.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".activities.StartFragment">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/trial_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="25dp"
android:layout_alignParentTop="true"
android:background="#drawable/trial_border"
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="top"
android:layout_marginRight="10dp"
android:layout_marginTop="3dp"
android:layout_marginLeft="10dp"
android:src="#drawable/ic_access_time_black_24dp" />
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:orientation="vertical">
<TextView
android:id="#+id/trial_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left|center"
android:text="#string/trial_exp"
android:textColor="#color/darkGrey"
android:textSize="15sp" />
<TextView
android:id="#+id/trial_more"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="right|center"
android:text="#string/trial_exp_more"
android:textColor="#color/darkGreen"
android:layout_marginRight="10dp"
android:textSize="13sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/main_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/trial_button"
android:layout_centerVertical="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="#+id/VImage"
android:layout_width="wrap_content"
android:layout_height="200sp"
android:src="#drawable/image_global" />
<TextView
android:id="#+id/VText"
android:layout_width="match_parent"
android:layout_height="40dp"
android:gravity="center"
android:text="#string/protection_disabled"
android:textColor="#color/darkRed"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:gravity="center"
android:orientation="vertical">
<com.google.android.material.button.MaterialButton
android:id="#+id/start_vpn_button"
style="#style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="141dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="#string/protect_me"
android:textColor="#color/white"
android:textStyle="bold"
app:backgroundTint="#color/green" />
<com.google.android.material.button.MaterialButton
android:id="#+id/stop_vpn_button"
style="#style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="141dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="#string/unprotect_me"
android:textColor="#color/white"
android:textStyle="bold"
android:visibility="gone"
app:backgroundTint="#color/red" />
</LinearLayout>
<LinearLayout
android:id="#+id/r_button"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="50sp"
android:layout_marginRight="20dp"
android:background="#drawable/single_border"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
android:orientation="horizontal">
<ImageView
android:id="#+id/r_image"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center"
android:src="#drawable/image_r_50" />
<TextView
android:id="#+id/r_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left|center"
android:text="#string/r_to"
android:textColor="#color/darkGrey"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>

Android : How to Create Dividers between Components

My goal is to obtain divider lines similar to the ones shown in the following picture:
Goal Picture Divider
I need to place a horizontal and vertical divider between LinearLayout
This is my User Interface XML Code:
<?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"
tools:context=".MainActivity"
android:background="#drawable/maingradiant">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:orientation="vertical"
android:gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:gravity="center"
android:orientation="horizontal">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/wheatallergyambericon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="اطلاعات ورودی"
android:textColor="#android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/wheatallergyambericon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="فاکتور"
android:textColor="#android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/wheatallergyambericon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="هزینه ها"
android:textColor="#android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/wheatallergyambericon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="تسویه"
android:textColor="#android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/wheatallergyambericon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="سامانه"
android:textColor="#android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/wheatallergyambericon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ارسال بار"
android:textColor="#android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
I am currently using RelativeLayout as the Root Element, and for each row, I am applying a horizontal LinearLayout followed by a vertical LinearLayout.
Based on my current layout, can I receive assistance on how to place the divider lines on my interface, much like the provided picture?
Thank you!
First of all, I would recomend you to use RecyclerView with GridLayoutManager for this purpose. creating recyclerview with gridmanager
but if you want stick with current design, you add line by creating a View in xml
For Vertical line
<View
android:layout_width="2dp" //thickness
android:layout_height="match_parent"
android:background="#color/colorPrimary" />
For Horizontal line
<View
android:layout_width="match_parent"
android:layout_height="2dp"//thickness
android:background="#color/colorPrimary" />
for shading colors you should look for something like Gradient in android. How ro create Gradient in android
code looks like this.
<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="#drawable/maingradiant"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:gravity="center"
android:orientation="horizontal">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/wheatallergyambericon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="اطلاعات ورودی"
android:textColor="#android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="#color/colorPrimary" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/wheatallergyambericon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="فاکتور"
android:textColor="#android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="#color/colorPrimary" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/wheatallergyambericon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="هزینه ها"
android:textColor="#android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#color/colorPrimary" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/wheatallergyambericon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="تسویه"
android:textColor="#android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="#color/colorPrimary" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/wheatallergyambericon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="سامانه"
android:textColor="#android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="#color/colorPrimary" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/wheatallergyambericon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ارسال بار"
android:textColor="#android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Happy coding!!

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>

How to Align an ImageView to the right side?

I want to set an imageview to the right side inside the cardview but aligning is not working... please suggest me
Layout
<FrameLayout
android:id="#+id/framelayout"
android:layout_height="match_parent"
android:layout_width="match_parent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/lin1"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="05dp"
android:layout_marginTop="15dp"
android:id="#+id/casardviewvisit">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#482048"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/omg"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20dp"
android:textColor="#fff"
android:textStyle="bold"
android:layout_marginLeft="20dp"
android:layout_gravity="center"
android:text="Add Order"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/sent"
android:layout_gravity="right"
android:id="#+id/imageButtsdon" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</framelayout>
Like this way i am trying but it is not working and i don't know why this is not working
Please use this code to set Imageview to right side inside CardView, just using the Relative layout.
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/casardviewvisit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="05dp"
android:layout_marginTop="15dp">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#482048">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="20dp"
android:text="Add Order"
android:textColor="#fff"
android:textSize="20dp"
android:textStyle="bold" />
<ImageButton
android:id="#+id/imageButtsdon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:src="#drawable/beautiful" />
</RelativeLayout>
</android.support.v7.widget.CardView>
Use RelativeLayout instead of LinearLayout
and add
android:layout_alignParentRight="true"
to the ImageView
thats all !!
Make your TextView stretched by doing
android:layout_width="0dp"
android:layout_weight="1"
You can use following code.
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="05dp"
android:layout_marginTop="15dp"
android:id="#+id/casardviewvisit">
<LinearLayout
android:weightSum="1"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#482048"
android:orientation="horizontal">
<ImageView
android:layout_weight=".2"
android:layout_width="0dp"
android:layout_height="50dp"
android:src="#drawable/test"/>
<TextView
android:layout_weight=".5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="20dp"
android:textColor="#fff"
android:textStyle="bold"
android:layout_marginLeft="20dp"
android:layout_gravity="center"
android:text="Add Order"/>
<ImageView
android:layout_weight=".2"
android:layout_width="0dp"
android:layout_height="50dp"
android:src="#drawable/test"
android:layout_gravity="right"
android:id="#+id/imageButtsdon" />
</LinearLayout>
</android.support.v7.widget.CardView>
You can copy and paste it your xml file
Just use simple gravity for your image view.
<FrameLayout
android:id="#+id/framelayout"
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/lin1"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="05dp"
android:layout_marginTop="15dp"
android:id="#+id/casardviewvisit">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#482048"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20dp"
android:textColor="#fff"
android:textStyle="bold"
android:layout_marginLeft="20dp"
android:layout_gravity="center"
android:text="Add Order"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/sent"
android:layout_gravity="right"
android:id="#+id/imageButtsdon" />
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_gravity="end"
android:layout_height="match_parent"
android:layout_marginRight="16dp"
android:src="#drawable/omg"/>
</android.support.v7.widget.CardView>
</LinearLayout>
</LinearLayout>
</FrameLayout>
Please check the following xml.
<FrameLayout
android:id="#+id/framelayout"
android:layout_height="match_parent"
android:layout_width="match_parent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/lin1"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="05dp"
android:layout_marginTop="15dp"
android:id="#+id/casardviewvisit">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#482048"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#482048"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20dp"
android:textColor="#fff"
android:textStyle="bold"
android:layout_marginLeft="20dp"
android:layout_gravity="center"
android:text="Add Order"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/sent"
android:layout_gravity="right"
android:id="#+id/imageButtsdon" />
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/omg"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</framelayout>
Inside the Cardview, the container LinearLayout just give Weightsum of 1 and give both the Imageviews a weight of .25 and textview a weight of .5 as shown below
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/casardviewvisit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="05dp"
android:layout_marginTop="15dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#482048"
android:orientation="horizontal"
android:weightSum="1" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:src="#drawable/omg" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="20dp"
android:layout_weight=".5"
android:text="Add Order"
android:textColor="#fff"
android:textSize="20dp"
android:textStyle="bold" />
<ImageButton
android:id="#+id/imageButtsdon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight=".2"
android:src="#drawable/sent" />
</LinearLayout>
</android.support.v7.widget.CardView>

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