How to align button to right in Scrollview? - android

I want the first button aligned to the left as it is and the other button below it to be aligned to the right.
I've tried a lot of stuff but nothing seems to work. Both buttons are in a scroll view.
Below is my XML Activity.
The background the buttons are using is an XML Drawable file with a shape.
<?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"
tools:context=".pg2">
<ScrollView
android:layout_width="395dp"
android:layout_height="match_parent"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView4"
android:layout_width="243.288590604dp"
android:layout_height="100dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:contentDescription="#string/logo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.151"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.035"
app:srcCompat="#drawable/frag11" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:fontFamily="#font/open_sans_semibold"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="#string/basic_rules_of_html"
android:textColor="#000000"
android:textSize="34sp" />
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="#string/str1"
android:textColor="#0A538F"
android:textSize="30sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:background="#DADADA"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="#string/str3"
android:textColor="#000000"
android:textSize="30sp" />
<TextView
android:id="#+id/textView4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="#string/str2"
android:textColor="#0A538F"
android:textSize="30sp" />
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="#string/str4"
android:textColor="#0A538F"
android:textSize="30sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:background="#DADADA"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="#string/str5"
android:textColor="#000000"
android:textSize="30sp" />
<TextView
android:id="#+id/textView8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="#string/str6"
android:textColor="#0A538F"
android:textSize="30sp" />
<Button
android:id="#+id/button2"
android:layout_width="135dp"
android:layout_height="50dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="20dp"
android:background="#drawable/button_fill"
android:fontFamily="#font/open_sans_semibold"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="#string/cont_"
android:textAlignment="textStart"
android:textColor="#FFFFFF"
android:textSize="18sp" />
<Button
android:id="#+id/button"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="#drawable/code"
android:text="#string/code"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="42sp"/>
<TextView
android:id="#+id/textView6"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
.
.
.
.
.
.
.
.
.
.
I would appreciate any help anyone can provide, I've tried a lot of stuff and nothing seems to work.

Please check below layout, I've updated your layout. I've just added a Framlayout as a parent of two Button.
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorWhite">
<ScrollView
android:layout_width="395dp"
android:layout_height="match_parent"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView4"
android:layout_width="243.288590604dp"
android:layout_height="100dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:contentDescription="#string/logo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.151"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.035"
app:srcCompat="#drawable/frag11" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:fontFamily="#font/open_sans_semibold"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="#string/basic_rules_of_html"
android:textColor="#000000"
android:textSize="34sp" />
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="#string/str1"
android:textColor="#0A538F"
android:textSize="30sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:background="#DADADA"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="#string/str3"
android:textColor="#000000"
android:textSize="30sp" />
<TextView
android:id="#+id/textView4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="#string/str2"
android:textColor="#0A538F"
android:textSize="30sp" />
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="#string/str4"
android:textColor="#0A538F"
android:textSize="30sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:background="#DADADA"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="#string/str5"
android:textColor="#000000"
android:textSize="30sp" />
<TextView
android:id="#+id/textView8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="#string/str6"
android:textColor="#0A538F"
android:textSize="30sp" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/button2"
android:layout_width="135dp"
android:layout_height="50dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="20dp"
android:background="#drawable/button_fill"
android:fontFamily="#font/open_sans_semibold"
android:paddingLeft="20dp"
android:layout_gravity="start|center_vertical"
android:paddingRight="20dp"
android:text="#string/cont_"
android:textAlignment="textStart"
android:textColor="#FFFFFF"
android:textSize="18sp" />
<Button
android:id="#+id/button"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:layout_marginRight="20dp"
android:layout_gravity="end"
android:layout_marginBottom="20dp"
android:background="#drawable/code"
android:text="#string/code"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="42sp" />
</FrameLayout>
<TextView
android:id="#+id/textView6"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>

Couple of answers here, have you tried:
android:gravity="start";
or if you want it to the right:
android:gravity="end";
failing that try and place each of the buttons in a linear layout and assigning the gravity to the layout instead.

You can use attribute android:layout_gravity="right"
in button

Related

Problems with the TextView position

I need to avoid textview touching each other, I tried many ways but I cant make it work.... What I should do? Thanks! Please view my screenshot
screenshot
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:background="#ffffff"
android:padding="15dp">
<ImageView
android:id="#+id/imageView"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_weight="0.11" />
<TextView
android:id="#+id/tvnombre"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toEndOf="#+id/imageView"
android:layout_toLeftOf="#+id/tvultvalor"
android:paddingLeft="15dp"
android:textColor="#333"
android:textSize="16dp"
android:layout_weight="1"
android:textStyle="bold" />
<TextView
android:id="#+id/tvdescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tvnombre"
android:layout_toEndOf="#+id/imageView"
android:layout_toRightOf="#+id/imageView"
android:layout_weight="1"
android:paddingLeft="15dp"
android:textColor="#333" />
<TextView
android:id="#+id/tvultvalor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="0dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:gravity="right"
android:paddingLeft="15dp"
android:textAlignment="gravity"
android:textColor="#333"
android:textStyle="bold" />
</RelativeLayout>
tvnombre is the id of the lef TextView, tvultvalor is the id of the right TextView
Thank you!
Try this
<LinearLayout
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/imageView"
android:layout_width="60dp"
android:layout_height="60dp"
android:padding="10dp"
android:src="#mipmap/ic_launcher" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="3">
<TextView
android:id="#+id/tv_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:paddingStart="16dp"
android:paddingEnd="16dp"
tools:text="Lorem Ipsum is simply dummy text of the " />
<TextView
android:id="#+id/tv_price"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:paddingStart="16dp"
android:paddingEnd="16dp"
tools:text="#string/contact_info" />
</LinearLayout>
<TextView
android:id="#+id/tv_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
tools:text="dummy text" />
</LinearLayout>
</LinearLayout>
The best way to achieve your layout is creating via Constraint Layout. Similar to what you did, I made a example that can fit for you. Hope this helps you! :-)
<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:id="#+id/relativeLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:background="#ffffff"
android:padding="15dp">
<ImageView
android:id="#+id/imageView"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_marginStart="16dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:layout_weight="0.11"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/tvnombre"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="#333"
android:textSize="16dp"
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="#+id/tvultvalor"
app:layout_constraintRight_toLeftOf="#+id/tvultvalor"
app:layout_constraintStart_toEndOf="#+id/imageView"
app:layout_constraintTop_toTopOf="#+id/imageView"
tools:text="dT/dt" />
<TextView
android:id="#+id/tvdescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#333"
app:layout_constraintLeft_toRightOf="#+id/imageView"
app:layout_constraintStart_toEndOf="#+id/imageView"
app:layout_constraintTop_toBottomOf="#+id/tvnombre"
tools:text="N TAG" />
<TextView
android:id="#+id/tvultvalor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:textAlignment="gravity"
android:textColor="#333"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="#+id/imageView"
tools:text="100 C" />
</android.support.constraint.ConstraintLayout>

How to disable scrollview for list view and apply scrollview for entire activity containing list views and other textviews?

I have an xml file containing different buttons, textviews, list views.Listview has default scrollview which is scrolling for certain part in an activity.But how to display all the "n" cells in list view by disabling scroll view and apply scroll view for entire page containing listviews,textviews,Buttons etc
xml file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#edecf2"
tools:context="com.bodaty.samyata.samyata09.orders.openorderdetails">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
tools:ignore="UselessParent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:orientation="vertical"
android:id="#+id/linearlayout"
tools:ignore="ScrollViewSize">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginTop="16dp"
android:orientation="horizontal"
android:padding="#dimen/activity_horizontal_margin"
app:cardCornerRadius="4dp"
app:cardElevation="2dp"
tools:targetApi="n">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="16dp"
android:orientation="horizontal">
<TextView
android:layout_width="170dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_weight="1"
android:fontFamily="#font/poppinsmedium"
android:gravity="start"
android:text="#string/store_pricen"
android:textAlignment="textStart"
android:textColor="#000000"
android:textSize="16sp"
tools:targetApi="n" />
<TextView
android:id="#+id/stprice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="30dp"
android:layout_marginStart="10dp" android:fontFamily="#font/montserratsemibold"
android:gravity="end"
android:lines="1"
android:layout_weight="1"
android:text="#string/price"
android:textAlignment="textEnd"
android:textColor="#000000"
android:textSize="16sp"
android:textStyle="bold"
tools:targetApi="n" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="0dp"
android:orientation="horizontal">
<TextView
android:layout_width="170dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_weight="1"
android:fontFamily="#font/poppinsmedium"
android:gravity="start"
android:text="#string/sales_tax"
android:textAlignment="textStart"
android:textColor="#000000"
android:textSize="16sp"
tools:targetApi="n" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:scrollbars="none"
android:layout_height="200dp"
android:background="#ffffff"
android:divider="#null"
/>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginTop="16dp"
android:orientation="horizontal"
android:padding="#dimen/activity_horizontal_margin"
app:cardCornerRadius="4dp"
app:cardElevation="2dp"
tools:targetApi="n">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="2"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:orientation="horizontal">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:background="#drawable/ic_action_storeicon"/>
<TextView
android:id="#+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="#string/store_location"
android:textAlignment="textStart"
android:textColor="#000000"
android:textSize="16sp"
android:fontFamily="#font/montserratsemibold"
tools:targetApi="n"
android:textStyle="bold"
android:gravity="start" />
</LinearLayout>
<TextView
android:id="#+id/st1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="8dp"
android:textAlignment="textStart"
android:layout_marginStart="20dp"
android:textColor="#7a7a7a"
android:textSize="14sp"
android:fontFamily="#font/poppinsmedium"
tools:targetApi="n"
android:gravity="start" />
<TextView
android:id="#+id/st2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="8dp"
android:textAlignment="textStart"
android:textColor="#7a7a7a"
android:textSize="14sp"
android:fontFamily="#font/poppinsmedium"
tools:targetApi="n"
android:gravity="start" />
<TextView
android:id="#+id/st3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="8dp"
android:textAlignment="textStart"
android:textColor="#7a7a7a"
android:textSize="14sp"
android:fontFamily="#font/poppinsmedium"
tools:targetApi="n"
android:gravity="start" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="8dp"
android:background="#808080">
</View>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#ffffff"
android:id="#+id/directions">
<TextView
android:id="#+id/ic1"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerVertical="true"
android:background="#drawable/placeholder"
android:layout_marginStart="10dp"
android:layout_alignParentStart="true"
android:fontFamily="#font/abeezee"
android:visibility="gone"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/way_to_the_storen"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:textStyle="bold"
android:textColor="#000000"
android:textSize="16sp"
android:fontFamily="#font/abeezee"
tools:ignore="RelativeOverlap" />
<Button
android:layout_width="30dp"
android:layout_height="30dp"
android:visibility="gone"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:background="#drawable/ic_action_forearr"
android:fontFamily="#font/abeezee"
/>
</RelativeLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/phide"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginTop="16dp"
android:orientation="horizontal"
android:padding="#dimen/activity_horizontal_margin"
app:cardCornerRadius="4dp"
app:cardElevation="2dp"
tools:targetApi="n">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="2"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:orientation="horizontal">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:background="#drawable/ic_action_locationorders"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="#string/dl"
android:textAlignment="textStart"
android:textColor="#000000"
android:textSize="16sp"
android:fontFamily="#font/questrial"
tools:targetApi="n"
android:textStyle="bold"
android:gravity="start" />
</LinearLayout>
<TextView
android:id="#+id/dl1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="8dp"
android:textAlignment="textStart"
android:layout_marginStart="20dp"
android:textColor="#7a7a7a"
android:textSize="14sp"
android:fontFamily="#font/questrial"
tools:targetApi="n"
android:gravity="start" />
<TextView
android:id="#+id/dl2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="8dp"
android:textAlignment="textStart"
android:textColor="#7a7a7a"
android:textSize="14sp"
android:fontFamily="#font/questrial"
tools:targetApi="n"
android:gravity="start" />
<TextView
android:id="#+id/dl3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="8dp"
android:textAlignment="textStart"
android:textColor="#7a7a7a"
android:textSize="14sp"
android:fontFamily="#font/questrial"
tools:targetApi="n"
android:gravity="start" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginTop="16dp"
android:orientation="horizontal"
android:padding="#dimen/activity_horizontal_margin"
app:cardCornerRadius="4dp"
app:cardElevation="2dp"
tools:targetApi="n">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2"
android:layout_marginBottom="2dp"
android:layout_marginTop="10dp"
>
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_marginEnd="10dp"
android:layout_marginStart="16dp"
android:background="#drawable/truck"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/deliverymethod"
android:textColor="#000000"
android:textSize="16sp"
android:textStyle="bold"
android:fontFamily="#font/montserratsemibold"
tools:targetApi="n"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="#string/personal_shopper"
android:textSize="16sp"
android:textColor="#000"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:id="#+id/delivery"
tools:ignore="InefficientWeight"
android:fontFamily="#font/poppinsmedium"
tools:targetApi="n"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#id/pslayout">
<TextView
android:id="#+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Personal Shopper Details"
android:layout_gravity="center_horizontal"
android:textSize="17sp"
android:textColor="#000000"
android:textStyle="bold"
android:layout_marginTop="10dp"
android:fontFamily="#font/poppinsmedium"
tools:targetApi="n"
tools:ignore="HardcodedText,InefficientWeight" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/top"
android:visibility="gone"
>
<ImageView
android:id="#+id/dp"
android:layout_width="138dp"
android:layout_height="150dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:background="#drawable/usn"
android:scaleType="centerCrop"
android:contentDescription="#string/todo"
tools:ignore="ContentDescription" />
<TextView
android:id="#+id/pstrack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Track your PersonalShopper"
android:textSize="17sp"
android:layout_gravity="center"
android:textColor="#000000"
android:textStyle="bold"
android:layout_marginTop="10dp"
android:fontFamily="#font/questrial"
tools:targetApi="n"
tools:ignore="HardcodedText,InefficientWeight" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="10dp"
android:layout_marginTop="20dp"
>
<TextView
android:id="#+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:fontFamily="#font/poppinsmedium"
android:text="#string/id1"
android:textColor="#000000"
android:textSize="16sp" />
<TextView
android:id="#+id/uid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:layout_marginStart="8dp"
android:fontFamily="#font/poppinsregular"
android:text="#string/random"
android:textColor="#000000"
android:textSize="14sp"
tools:targetApi="n" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:fontFamily="#font/poppinsmedium"
android:text="#string/delivery_status"
android:textColor="#000000"
android:textSize="16sp" />
<TextView
android:id="#+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:fontFamily="#font/poppinsregular"
android:text="#string/product_picked_up"
android:textColor="#000000"
android:textSize="14sp"
tools:ignore="InefficientWeight"
tools:targetApi="n" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>
</RelativeLayout>
set the height of listview to wrap_content

Constraint layout not aligning textview

i am using contraint layout to align my textview in each corner of the screen but it looks like it is not working. the text on the right size of the screen gets align according to text length on the left size. take a look at the attach pic. text on the right is not properly align. for some reason there are a few spaces off. how can fix that?
<?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="wrap_content">
<TextView
android:id="#+id/payout_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="12dp"
android:maxLines="1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/black"
android:text="#string/payout_label"
app:layout_constraintBottom_toTopOf="#+id/income_icon"/>
<ImageView
android:id="#+id/income_icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginTop="30dp"
android:layout_marginStart="8dp"
android:layout_marginBottom="-50dp"
android:padding="1dp"
android:scaleType="centerCrop"
android:src="#drawable/ic_income"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintVertical_chainStyle="packed" />
<TextView
android:id="#+id/category"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="16dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/black"
android:text="Salary"
app:layout_constraintTop_toTopOf="#+id/income_icon"
app:layout_constraintStart_toEndOf="#+id/income_icon"
/>
<TextView
android:id="#+id/income_amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="$0.00"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/green"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.91"
app:layout_constraintStart_toEndOf="#+id/category"
app:layout_constraintTop_toTopOf="#+id/income_icon" />
<TextView
android:id="#+id/frequency"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="-5dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/grey"
android:text="Monthly"
app:layout_constraintStart_toEndOf="#+id/income_icon"
app:layout_constraintBottom_toBottomOf="#+id/income_icon" />
<TextView
android:id="#+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pending"
android:textAppearance="#style/TextAppearance.AppCompat.Body2"
android:textColor="#color/grey"
app:layout_constraintBottom_toBottomOf="#+id/income_icon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.91"
app:layout_constraintStart_toEndOf="#+id/frequency" />
</android.support.constraint.ConstraintLayout>
If you want the amount to be right-justified and aligned, you don't need the following two lines of XML:
app:layout_constraintHorizontal_bias="0.91"
app:layout_constraintStart_toEndOf="#+id/category"
So, just delete them to give the following:
<TextView
android:id="#+id/income_amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="$0.00"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/green"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="#+id/income_icon" />
If you need a margin on the right of, say, 16dp, add:
android:layout_marginEnd="16dp"
your mistakes are these - you must remove these
this line in income_amount
app:layout_constraintStart_toEndOf="#+id/category"
this line in status
app:layout_constraintStart_toEndOf="#+id/frequency"
this is correct design
<?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="wrap_content">
<TextView
android:id="#+id/payout_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="12dp"
android:maxLines="1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/black"
android:text="payout_label"
app:layout_constraintBottom_toTopOf="#+id/income_icon"/>
<ImageView
android:id="#+id/income_icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginTop="30dp"
android:layout_marginStart="8dp"
android:layout_marginBottom="-50dp"
android:padding="1dp"
android:scaleType="centerCrop"
android:src="#drawable/leak_canary_icon"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintVertical_chainStyle="packed" />
<TextView
android:id="#+id/category"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="8dp"
android:text="Salary"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/black"
app:layout_constraintEnd_toStartOf="#+id/income_amount"
app:layout_constraintStart_toEndOf="#+id/income_icon"
app:layout_constraintTop_toTopOf="#+id/income_icon"/>
<TextView
android:id="#+id/income_amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="$0.00"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/green"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="#+id/income_icon"/>
<TextView
android:id="#+id/frequency"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="-5dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="8dp"
android:text="Monthly"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/grey"
app:layout_constraintBottom_toBottomOf="#+id/income_icon"
app:layout_constraintEnd_toStartOf="#+id/status"
app:layout_constraintStart_toEndOf="#+id/income_icon"/>
<TextView
android:id="#+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="Pending"
android:textAppearance="#style/TextAppearance.AppCompat.Body2"
android:textColor="#color/grey"
app:layout_constraintBottom_toBottomOf="#+id/income_icon"
app:layout_constraintEnd_toEndOf="parent"/>
</android.support.constraint.ConstraintLayout>
I have aligned the status TextView to amount TextView and have given an 8 dp from right to status TextView so that it aligns to the amount TextView. Below is the code for it.
<?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="wrap_content">
<TextView
android:id="#+id/payout_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="12dp"
android:maxLines="1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/black"
android:text="payout_label"
app:layout_constraintBottom_toTopOf="#+id/income_icon"/>
<ImageView
android:id="#+id/income_icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginTop="30dp"
android:layout_marginStart="8dp"
android:layout_marginBottom="-50dp"
android:padding="1dp"
android:scaleType="centerCrop"
android:src="#drawable/ic_launcher_background"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintVertical_chainStyle="packed"
android:layout_marginLeft="8dp" />
<TextView
android:id="#+id/category"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="16dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/black"
android:text="Salary"
app:layout_constraintTop_toTopOf="#+id/income_icon"
app:layout_constraintStart_toEndOf="#+id/income_icon"
android:layout_marginLeft="5dp"
android:layout_marginRight="16dp" />
<TextView
android:id="#+id/income_amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="$0.00"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/holo_green_light"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.91"
app:layout_constraintStart_toEndOf="#+id/category"
app:layout_constraintTop_toTopOf="#+id/income_icon" />
<TextView
android:id="#+id/frequency"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="-5dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#android:color/darker_gray"
android:text="Monthly"
app:layout_constraintStart_toEndOf="#+id/income_icon"
app:layout_constraintBottom_toBottomOf="#+id/income_icon"
android:layout_marginLeft="5dp"
android:layout_marginRight="16dp" />
<TextView
android:id="#+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:text="Pending"
android:textAppearance="#style/TextAppearance.AppCompat.Body2"
android:textColor="#android:color/darker_gray"
app:layout_constraintBottom_toBottomOf="#+id/income_icon"
app:layout_constraintEnd_toEndOf="#+id/income_amount"
app:layout_constraintStart_toStartOf="#+id/income_amount" />
</android.support.constraint.ConstraintLayout>
Hope that helps!!!!
Design your layout like below.
<?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="wrap_content"
android:padding="#dimen/_5sdp">
<TextView
android:id="#+id/payout_date"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_5sdp"
android:maxLines="1"
android:text="payout_label"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/color_black"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/income_icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginTop="#dimen/_5sdp"
android:padding="1dp"
android:scaleType="centerCrop"
android:src="#drawable/ic_inbox_active"
app:layout_constraintLeft_toLeftOf="#+id/payout_date"
app:layout_constraintTop_toBottomOf="#+id/payout_date"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="30dp" />
<TextView
android:id="#+id/category"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Salary"
android:layout_marginRight="#dimen/_5sdp"
android:layout_marginStart="#dimen/_5sdp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/color_black"
app:layout_constraintLeft_toRightOf="#+id/income_icon"
app:layout_constraintRight_toLeftOf="#+id/income_amount"
app:layout_constraintTop_toTopOf="#+id/income_icon"
tools:layout_editor_absoluteX="61dp"
tools:layout_editor_absoluteY="34dp" />
<TextView
android:id="#+id/income_amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="$0.00"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/color_black"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/payout_date"
tools:layout_editor_absoluteX="344dp"
tools:layout_editor_absoluteY="30dp" />
<TextView
android:id="#+id/frequency"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Monthly"
app:layout_constraintLeft_toLeftOf="#+id/category"
app:layout_constraintTop_toBottomOf="#+id/category"
app:layout_constraintRight_toLeftOf="#+id/status"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/color_black"
tools:layout_editor_absoluteX="61dp"
tools:layout_editor_absoluteY="59dp" />
<TextView
android:id="#+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pending"
android:textAppearance="#style/TextAppearance.AppCompat.Body2"
android:textColor="#color/color_black"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/income_amount" />
</android.support.constraint.ConstraintLayout>

ConstraintLayout Stuck at Parent top despite being constrained to View

Searched around, can't find this issue specifically. Created an account specifically to ask WHAT'S HAPPENING HERE?!
Using a ConstraintLayout for the first time - I've had good success, but for some reason CANNOT get two of my Components to play nicely.
Here's what I WANT it to look like (accomplished by breaking constraints and hardcoding stuff):
...and here's the jumbled mess I get if I try to constrain "LabelJournal" and "linearLayout2":
The problems are happening for components named "LabelJournal" and "linearLayout2". Here's what my LayoutFile looks like... It's a WIP so I know right now there's a lot of hardcoding of text values and whatnot - I'm just trying to figure out WHAT in the world is causing these two components to get stuck at the top of the parent:
<?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">
<ImageButton
android:id="#+id/imageButton"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#android:color/transparent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_left" />
<EditText
android:id="#+id/editText"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginEnd="14dp"
android:layout_marginStart="14dp"
android:inputType="date"
android:text="03/04/2018"
android:textAlignment="center"
android:textSize="24sp"
app:layout_constraintEnd_toStartOf="#+id/imageButton2"
app:layout_constraintStart_toEndOf="#+id/imageButton"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="#+id/imageButton2"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#android:color/transparent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_right" />
<TextView
android:id="#+id/LabelJournal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:text="Journal:"
android:textStyle="italic"
app:layout_constraintBottom_toTopOf="#id/ContentJournal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageButton" />
<TextView
android:id="#+id/ContentJournal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:text="The journal text would go in right about here. It should wrap to the next line for sufficientyl large text blocks."
android:textColorLink="#android:color/black"
android:textSize="18sp"
app:layout_constraintBottom_toTopOf="#+id/LabelTags"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/LabelJournal" />
<TextView
android:id="#+id/LabelTags"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginStart="16dp"
android:text="Tags:"
android:textStyle="italic"
app:layout_constraintBottom_toTopOf="#+id/horizontalScrollView"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#id/ContentJournal" />
<HorizontalScrollView
android:id="#+id/horizontalScrollView"
android:layout_width="0dp"
android:layout_height="41dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/LabelTags">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/TagDayOff"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:padding="10dp"
android:paddingBottom="15dp"
android:paddingTop="15dp"
android:text="#DayOff"
android:textAlignment="center"
android:textColor="#android:color/darker_gray"
android:textSize="18sp" />
<TextView
android:id="#+id/TagUntracked"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:padding="10dp"
android:paddingBottom="15dp"
android:paddingTop="15dp"
android:text="#Untracked"
android:textAlignment="center"
android:textColor="#android:color/darker_gray"
android:textSize="18sp" />
<TextView
android:id="#+id/TagTravel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:padding="10dp"
android:paddingBottom="15dp"
android:paddingTop="15dp"
android:text="#Travel"
android:textAlignment="center"
android:textColor="#android:color/darker_gray"
android:textSize="18sp" />
<TextView
android:id="#+id/TagGames"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:padding="10dp"
android:paddingBottom="15dp"
android:paddingTop="15dp"
android:text="#Games"
android:textAlignment="center"
android:textColor="#android:color/darker_gray"
android:textSize="18sp" />
<TextView
android:id="#+id/TagMovie"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:padding="10dp"
android:paddingBottom="15dp"
android:paddingTop="15dp"
android:text="#Games"
android:textAlignment="center"
android:textColor="#android:color/darker_gray"
android:textSize="18sp" />
</LinearLayout>
</HorizontalScrollView>
<TextView
android:id="#+id/LabelDIet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:text="Diet:"
android:textStyle="italic"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/horizontalScrollView" />
<TextView
android:id="#+id/ContentCalories"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="8dp"
android:textSize="18sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/LabelDIet"
tools:text="2813" />
<TextView
android:id="#+id/DietCalLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="Cal"
android:textSize="10sp"
android:textStyle="italic"
app:layout_constraintBottom_toBottomOf="#+id/ContentCalories"
app:layout_constraintStart_toEndOf="#+id/ContentCalories" />
<ProgressBar
android:id="#+id/ProgressCalories"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="2dp"
android:layout_marginEnd="-8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="2dp"
android:progressDrawable="#android:color/holo_blue_dark"
android:progressTint="#android:color/holo_green_light"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="#+id/ContentCalories"
app:layout_constraintEnd_toEndOf="#+id/ContentProteinPercent"
app:layout_constraintStart_toEndOf="#+id/DietCalLabel"
app:layout_constraintTop_toTopOf="#+id/ContentCalories" />
<TextView
android:id="#+id/ContentProtein"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginTop="8dp"
android:textSize="18sp"
app:layout_constraintEnd_toStartOf="#+id/DietCalLabel"
app:layout_constraintTop_toBottomOf="#+id/ContentCalories"
tools:text="154" />
<TextView
android:id="#+id/DietProteinLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="P"
android:textSize="10sp"
android:textStyle="italic"
app:layout_constraintBottom_toBottomOf="#+id/ContentProtein"
app:layout_constraintStart_toEndOf="#+id/ContentProtein" />
<ProgressBar
android:id="#+id/ProgressProtein"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="150dp"
android:layout_height="0dp"
android:layout_marginBottom="4dp"
android:layout_marginStart="8dp"
android:layout_marginTop="4dp"
android:progressDrawable="#android:color/holo_blue_dark"
android:progressTint="#android:color/holo_red_light"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="#+id/ContentProtein"
app:layout_constraintStart_toEndOf="#+id/DietCalLabel"
app:layout_constraintTop_toTopOf="#+id/ContentProtein" />
<TextView
android:id="#+id/ContentProteinPercent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:paddingEnd="8dp"
android:paddingStart="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.074"
app:layout_constraintStart_toEndOf="#+id/ProgressProtein"
app:layout_constraintTop_toTopOf="#+id/ContentProtein"
tools:text="22 %" />
<TextView
android:id="#+id/ContentFat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginTop="8dp"
android:textSize="18sp"
app:layout_constraintEnd_toStartOf="#+id/DietCalLabel"
app:layout_constraintTop_toBottomOf="#+id/ContentProtein"
tools:text="103" />
<TextView
android:id="#+id/dietProteinLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="F"
android:textSize="10sp"
android:textStyle="italic"
app:layout_constraintBottom_toBottomOf="#+id/ContentFat"
app:layout_constraintStart_toEndOf="#+id/ContentFat" />
<ProgressBar
android:id="#+id/ProgressFats"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="150dp"
android:layout_height="0dp"
android:layout_marginBottom="4dp"
android:layout_marginStart="8dp"
android:layout_marginTop="4dp"
android:progressDrawable="#android:color/holo_blue_dark"
android:progressTint="#android:color/holo_orange_light"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="#+id/ContentFat"
app:layout_constraintStart_toEndOf="#+id/DietCalLabel"
app:layout_constraintTop_toTopOf="#+id/ContentFat" />
<TextView
android:id="#+id/contentProteinPercent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:paddingEnd="8dp"
android:paddingStart="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.074"
app:layout_constraintStart_toEndOf="#+id/ProgressProtein"
app:layout_constraintTop_toTopOf="#+id/ContentFat"
tools:text="33 %" />
<TextView
android:id="#+id/ContentCarbs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginTop="8dp"
android:textSize="18sp"
app:layout_constraintEnd_toStartOf="#+id/DietCalLabel"
app:layout_constraintTop_toBottomOf="#+id/ContentFat"
tools:text="302" />
<TextView
android:id="#+id/DietCarbLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="C"
android:textSize="10sp"
android:textStyle="italic"
app:layout_constraintBottom_toBottomOf="#+id/ContentCarbs"
app:layout_constraintStart_toEndOf="#+id/ContentCarbs" />
<ProgressBar
android:id="#+id/ProgressCarbs"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="150dp"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:progressDrawable="#android:color/holo_blue_dark"
android:progressTint="#android:color/holo_blue_light"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="#+id/ContentCarbs"
app:layout_constraintStart_toEndOf="#+id/DietCalLabel"
app:layout_constraintTop_toTopOf="#+id/ContentCarbs" />
<TextView
android:id="#+id/ContentCarbPercent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:paddingEnd="8dp"
android:paddingStart="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.074"
app:layout_constraintStart_toEndOf="#+id/ProgressProtein"
app:layout_constraintTop_toTopOf="#+id/ContentCarbs"
tools:text="43 %" />
<TextView
android:id="#+id/LabelExercise"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:text="Exercise:"
android:textStyle="italic"
app:layout_constraintBottom_toTopOf="#+id/linearLayout2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/ContentCarbs" />
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="436dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/LabelExercise" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageButton
android:id="#+id/ImageExerciseAttribution"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_weight="1"
android:background="#android:color/transparent"
android:scaleType="fitXY"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/LabelExercise"
app:srcCompat="#drawable/fit" />
<TextView
android:id="#+id/ContentExercise"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:text="45 min - PHUL Upper Power"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="#+id/ImageExerciseAttribution"
app:layout_constraintStart_toEndOf="#+id/ImageExerciseAttribution"
app:layout_constraintTop_toTopOf="#+id/ImageExerciseAttribution" />
</LinearLayout>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
Perhaps I should also mention - I have no errors showing up in my Constraint Layout (although a ton of warnings about hardcoded text and whatnot that I'll deal with later).
Alright took me an hour of tinkering - but ever line in my Layout HTML that contains "layout_constraintBottom_toTopOf" caused the problem. I don't know if it's an ordering thing or some weird drawing hierarchy. It makes no sense to me how this got busted.

One RelativeLayout Above another

I have layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/text_color"
android:minHeight="285dp"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/credit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="-30dp">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="#drawable/bonus_badge"/>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="6dp"
android:text="Get"
android:textColor="#color/black"
android:textSize="12sp"/>
<!-- don't change this layout view order -->
<TextView
android:id="#+id/amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="18dp"
android:text="$1xxx"
android:textColor="#color/black"
android:textSize="14sp"
android:textStyle="bold"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<ImageView
android:id="#+id/image"
android:layout_width="162dp"
android:layout_height="112dp"
android:adjustViewBounds="true"
android:src="#drawable/test_image"/>
<ImageView
android:id="#+id/topFlag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="#drawable/sold_out"
android:visibility="gone"/>
<ImageView
android:id="#+id/waitListFlag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="#drawable/join_wait_list"
android:visibility="gone"/>
</RelativeLayout>
<TextView
android:id="#+id/options"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:text="Options"
android:textColor="#color/unactive_color"
android:textSize="14sp"/>
<TextView
android:id="#+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:ellipsize="end"
android:maxHeight="80dp"
android:maxLines="3"
android:minHeight="40dp"
android:minLines="3"
android:text="name"
android:textColor="#color/dark_cyan"
android:textSize="16sp"/>
<TextView
android:id="#+id/oldPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:text="old price"
android:textColor="#color/unactive_color"
android:textSize="14sp"/>
<TextView
android:id="#+id/newPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:text="new price"
android:textColor="#color/price_black"
android:textSize="22sp"/>
<TextView
android:id="#+id/Save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:text="save"
android:textColor="#color/unactive_color"
android:textSize="14sp"/>
<View
android:id="#+id/view1"
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_marginTop="10dp"
android:background="#color/divider_color_product"/>
</LinearLayout>
And Actual result is:
But I need something like that:
The problem is with the yellow-badge android:id="#+id/credit".
I need to have it above the image which the space before.
I'm trying to set programmatically bringToFront(); but nothing happens.
Also I'm trying to play with layout_below layout_above attributes.
Where is the problem ? Anyway, thank you!
It seems that the second RelativeLayout is the big image, and the first is the tag. So I modify the xml below, hope this is what you want :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/text_color"
android:minHeight="285dp"
android:orientation="vertical">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<ImageView
android:id="#+id/image"
android:layout_width="162dp"
android:layout_height="112dp"
android:adjustViewBounds="true"
android:src="#drawable/test_image" />
<ImageView
android:id="#+id/topFlag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="#drawable/sold_out"
android:visibility="gone" />
<ImageView
android:id="#+id/waitListFlag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="#drawable/join_wait_list"
android:visibility="gone" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/credit"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="#drawable/bonus_badge" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="6dp"
android:text="Get"
android:textColor="#color/black"
android:textSize="12sp" />
<!-- don't change this layout view order -->
<TextView
android:id="#+id/amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="18dp"
android:text="$1xxx"
android:textColor="#color/black"
android:textSize="14sp"
android:textStyle="bold" />
</RelativeLayout>
</FrameLayout>
<TextView
android:id="#+id/options"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:text="Options"
android:textColor="#color/unactive_color"
android:textSize="14sp" />
<TextView
android:id="#+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:ellipsize="end"
android:maxHeight="80dp"
android:maxLines="3"
android:minHeight="40dp"
android:minLines="3"
android:text="name"
android:textColor="#color/dark_cyan"
android:textSize="16sp" />
<TextView
android:id="#+id/oldPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:text="old price"
android:textColor="#color/unactive_color"
android:textSize="14sp" />
<TextView
android:id="#+id/newPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:text="new price"
android:textColor="#color/price_black"
android:textSize="22sp" />
<TextView
android:id="#+id/Save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:text="save"
android:textColor="#color/unactive_color"
android:textSize="14sp" />
<View
android:id="#+id/view1"
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_marginTop="10dp"
android:background="#color/divider_color_product" />
</LinearLayout>
create you parent relativelayout , then and what you want inside it , to get overlay effect , you should know that the blow layout appear in the above of the pervious layout
--relativelayout
|
---------ImageView
|
---------Relativelayout (let it alignParentTop)
|
------ImageView
|
------TextView(center in parent)

Categories

Resources