converting linear layout to constraint layout results in view too left










0















I had this nested linear layouts



 <LinearLayout
android:id="@+id/has_selected_account"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/account_menu_header_signed_in_vertical_margin"
android:layout_marginBottom="@dimen/account_menu_header_signed_in_vertical_margin"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/close_and_recents"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.myImage
android:id="@+id/account_avatar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/account_menu_header_signed_in_avatar_margin_start"
android:layout_marginEnd="@dimen/account_menu_header_signed_in_avatar_margin_end"
android:layout_marginLeft="@dimen/account_menu_header_signed_in_avatar_margin_start"
android:layout_marginRight="@dimen/account_menu_header_signed_in_avatar_margin_end"
android:contentDescription="@null"
app:imageViewSize="@dimen/account_menu_header_signed_in_disc_size"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="@dimen/account_menu_name_and_display_vertical_padding"
android:paddingBottom="@dimen/account_menu_name_and_display_vertical_padding"
android:orientation="vertical">
<TextView
android:id="@+id/account_display_name"
style="@style/AccountDataDisplayName"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical"
tools:text="DisplayNameIsLongSoItShouldBeTruncatedAtSomePoint"/>
<TextView
android:id="@+id/account_name"
style="@style/AccountDataAccountName"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|start"
android:includeFontPadding="false"
tools:text="emailisverylongaswellwewantittogettruncated@gmail.longdomain.com"/>
</LinearLayout>
</LinearLayout>


and i wanted to convert it to one constraint layout:



 <merge>
<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/has_selected_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/google_blue100">
<com.myView
android:id="@+id/account_avatar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/account_menu_header_signed_in_avatar_margin_start"
android:layout_marginEnd="@dimen/account_menu_header_signed_in_avatar_margin_end"
android:layout_marginLeft="@dimen/account_menu_header_signed_in_avatar_margin_start"
android:layout_marginRight="@dimen/account_menu_header_signed_in_avatar_margin_end"
android:contentDescription="@null"
app:imageViewSize="@dimen/account_menu_header_signed_in_disc_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<View
android:id="@+id/account_display_name_top_padding"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="@dimen/account_menu_name_and_display_vertical_padding"
android:background="@color/google_red50"
app:layout_constraintBottom_toTopOf="@id/account_display_name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/account_avatar"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/account_display_name"
style="@style/AccountDataDisplayName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/google_red100"
android:gravity="center_vertical"
android:includeFontPadding="false"
app:layout_constraintBottom_toTopOf="@+id/account_name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toEndOf="@+id/account_avatar"
app:layout_constraintTop_toTopOf="@+id/account_display_name_top_padding"
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintWidth_default="wrap"
tools:text="DisplayNameIssLongSoItShouldBeTruncatedAtSomePoint"/>
<TextView
android:id="@+id/account_name"
style="@style/AccountDataAccountName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/google_green100"
android:gravity="center_vertical"
android:includeFontPadding="false"
app:layout_constraintBottom_toBottomOf="@+id/account_name_bottom_padding"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toEndOf="@+id/account_avatar"
app:layout_constraintTop_toBottomOf="@+id/account_display_name"
app:layout_constraintWidth_default="wrap"
tools:text="emailisverylongaswellwewantittogettruncated@gmail.longdomain.com"/>
<View
android:id="@+id/account_name_bottom_padding"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="@dimen/account_menu_name_and_display_vertical_padding"
android:background="@color/google_red50"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/account_avatar"
app:layout_constraintTop_toBottomOf="@id/account_name"/>
</android.support.constraint.ConstraintLayout>
</merge>


The result was almost OK, but the textViews are going too up and too close to the Image view.



here is the new result overlapping the old ui:



enter image description here



Does anyone have an idea why? or how to solve this?



I have added margin left to the imageView but it didn't seem to change anything.










share|improve this question






















  • Why would you add a left margin to your ImageView if it's already too close to the TextViews?

    – TheWanderer
    Nov 13 '18 at 22:57















0















I had this nested linear layouts



 <LinearLayout
android:id="@+id/has_selected_account"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/account_menu_header_signed_in_vertical_margin"
android:layout_marginBottom="@dimen/account_menu_header_signed_in_vertical_margin"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/close_and_recents"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.myImage
android:id="@+id/account_avatar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/account_menu_header_signed_in_avatar_margin_start"
android:layout_marginEnd="@dimen/account_menu_header_signed_in_avatar_margin_end"
android:layout_marginLeft="@dimen/account_menu_header_signed_in_avatar_margin_start"
android:layout_marginRight="@dimen/account_menu_header_signed_in_avatar_margin_end"
android:contentDescription="@null"
app:imageViewSize="@dimen/account_menu_header_signed_in_disc_size"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="@dimen/account_menu_name_and_display_vertical_padding"
android:paddingBottom="@dimen/account_menu_name_and_display_vertical_padding"
android:orientation="vertical">
<TextView
android:id="@+id/account_display_name"
style="@style/AccountDataDisplayName"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical"
tools:text="DisplayNameIsLongSoItShouldBeTruncatedAtSomePoint"/>
<TextView
android:id="@+id/account_name"
style="@style/AccountDataAccountName"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|start"
android:includeFontPadding="false"
tools:text="emailisverylongaswellwewantittogettruncated@gmail.longdomain.com"/>
</LinearLayout>
</LinearLayout>


and i wanted to convert it to one constraint layout:



 <merge>
<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/has_selected_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/google_blue100">
<com.myView
android:id="@+id/account_avatar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/account_menu_header_signed_in_avatar_margin_start"
android:layout_marginEnd="@dimen/account_menu_header_signed_in_avatar_margin_end"
android:layout_marginLeft="@dimen/account_menu_header_signed_in_avatar_margin_start"
android:layout_marginRight="@dimen/account_menu_header_signed_in_avatar_margin_end"
android:contentDescription="@null"
app:imageViewSize="@dimen/account_menu_header_signed_in_disc_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<View
android:id="@+id/account_display_name_top_padding"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="@dimen/account_menu_name_and_display_vertical_padding"
android:background="@color/google_red50"
app:layout_constraintBottom_toTopOf="@id/account_display_name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/account_avatar"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/account_display_name"
style="@style/AccountDataDisplayName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/google_red100"
android:gravity="center_vertical"
android:includeFontPadding="false"
app:layout_constraintBottom_toTopOf="@+id/account_name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toEndOf="@+id/account_avatar"
app:layout_constraintTop_toTopOf="@+id/account_display_name_top_padding"
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintWidth_default="wrap"
tools:text="DisplayNameIssLongSoItShouldBeTruncatedAtSomePoint"/>
<TextView
android:id="@+id/account_name"
style="@style/AccountDataAccountName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/google_green100"
android:gravity="center_vertical"
android:includeFontPadding="false"
app:layout_constraintBottom_toBottomOf="@+id/account_name_bottom_padding"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toEndOf="@+id/account_avatar"
app:layout_constraintTop_toBottomOf="@+id/account_display_name"
app:layout_constraintWidth_default="wrap"
tools:text="emailisverylongaswellwewantittogettruncated@gmail.longdomain.com"/>
<View
android:id="@+id/account_name_bottom_padding"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="@dimen/account_menu_name_and_display_vertical_padding"
android:background="@color/google_red50"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/account_avatar"
app:layout_constraintTop_toBottomOf="@id/account_name"/>
</android.support.constraint.ConstraintLayout>
</merge>


The result was almost OK, but the textViews are going too up and too close to the Image view.



here is the new result overlapping the old ui:



enter image description here



Does anyone have an idea why? or how to solve this?



I have added margin left to the imageView but it didn't seem to change anything.










share|improve this question






















  • Why would you add a left margin to your ImageView if it's already too close to the TextViews?

    – TheWanderer
    Nov 13 '18 at 22:57













0












0








0


0






I had this nested linear layouts



 <LinearLayout
android:id="@+id/has_selected_account"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/account_menu_header_signed_in_vertical_margin"
android:layout_marginBottom="@dimen/account_menu_header_signed_in_vertical_margin"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/close_and_recents"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.myImage
android:id="@+id/account_avatar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/account_menu_header_signed_in_avatar_margin_start"
android:layout_marginEnd="@dimen/account_menu_header_signed_in_avatar_margin_end"
android:layout_marginLeft="@dimen/account_menu_header_signed_in_avatar_margin_start"
android:layout_marginRight="@dimen/account_menu_header_signed_in_avatar_margin_end"
android:contentDescription="@null"
app:imageViewSize="@dimen/account_menu_header_signed_in_disc_size"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="@dimen/account_menu_name_and_display_vertical_padding"
android:paddingBottom="@dimen/account_menu_name_and_display_vertical_padding"
android:orientation="vertical">
<TextView
android:id="@+id/account_display_name"
style="@style/AccountDataDisplayName"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical"
tools:text="DisplayNameIsLongSoItShouldBeTruncatedAtSomePoint"/>
<TextView
android:id="@+id/account_name"
style="@style/AccountDataAccountName"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|start"
android:includeFontPadding="false"
tools:text="emailisverylongaswellwewantittogettruncated@gmail.longdomain.com"/>
</LinearLayout>
</LinearLayout>


and i wanted to convert it to one constraint layout:



 <merge>
<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/has_selected_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/google_blue100">
<com.myView
android:id="@+id/account_avatar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/account_menu_header_signed_in_avatar_margin_start"
android:layout_marginEnd="@dimen/account_menu_header_signed_in_avatar_margin_end"
android:layout_marginLeft="@dimen/account_menu_header_signed_in_avatar_margin_start"
android:layout_marginRight="@dimen/account_menu_header_signed_in_avatar_margin_end"
android:contentDescription="@null"
app:imageViewSize="@dimen/account_menu_header_signed_in_disc_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<View
android:id="@+id/account_display_name_top_padding"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="@dimen/account_menu_name_and_display_vertical_padding"
android:background="@color/google_red50"
app:layout_constraintBottom_toTopOf="@id/account_display_name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/account_avatar"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/account_display_name"
style="@style/AccountDataDisplayName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/google_red100"
android:gravity="center_vertical"
android:includeFontPadding="false"
app:layout_constraintBottom_toTopOf="@+id/account_name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toEndOf="@+id/account_avatar"
app:layout_constraintTop_toTopOf="@+id/account_display_name_top_padding"
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintWidth_default="wrap"
tools:text="DisplayNameIssLongSoItShouldBeTruncatedAtSomePoint"/>
<TextView
android:id="@+id/account_name"
style="@style/AccountDataAccountName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/google_green100"
android:gravity="center_vertical"
android:includeFontPadding="false"
app:layout_constraintBottom_toBottomOf="@+id/account_name_bottom_padding"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toEndOf="@+id/account_avatar"
app:layout_constraintTop_toBottomOf="@+id/account_display_name"
app:layout_constraintWidth_default="wrap"
tools:text="emailisverylongaswellwewantittogettruncated@gmail.longdomain.com"/>
<View
android:id="@+id/account_name_bottom_padding"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="@dimen/account_menu_name_and_display_vertical_padding"
android:background="@color/google_red50"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/account_avatar"
app:layout_constraintTop_toBottomOf="@id/account_name"/>
</android.support.constraint.ConstraintLayout>
</merge>


The result was almost OK, but the textViews are going too up and too close to the Image view.



here is the new result overlapping the old ui:



enter image description here



Does anyone have an idea why? or how to solve this?



I have added margin left to the imageView but it didn't seem to change anything.










share|improve this question














I had this nested linear layouts



 <LinearLayout
android:id="@+id/has_selected_account"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/account_menu_header_signed_in_vertical_margin"
android:layout_marginBottom="@dimen/account_menu_header_signed_in_vertical_margin"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/close_and_recents"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.myImage
android:id="@+id/account_avatar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/account_menu_header_signed_in_avatar_margin_start"
android:layout_marginEnd="@dimen/account_menu_header_signed_in_avatar_margin_end"
android:layout_marginLeft="@dimen/account_menu_header_signed_in_avatar_margin_start"
android:layout_marginRight="@dimen/account_menu_header_signed_in_avatar_margin_end"
android:contentDescription="@null"
app:imageViewSize="@dimen/account_menu_header_signed_in_disc_size"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="@dimen/account_menu_name_and_display_vertical_padding"
android:paddingBottom="@dimen/account_menu_name_and_display_vertical_padding"
android:orientation="vertical">
<TextView
android:id="@+id/account_display_name"
style="@style/AccountDataDisplayName"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical"
tools:text="DisplayNameIsLongSoItShouldBeTruncatedAtSomePoint"/>
<TextView
android:id="@+id/account_name"
style="@style/AccountDataAccountName"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical|start"
android:includeFontPadding="false"
tools:text="emailisverylongaswellwewantittogettruncated@gmail.longdomain.com"/>
</LinearLayout>
</LinearLayout>


and i wanted to convert it to one constraint layout:



 <merge>
<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/has_selected_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/google_blue100">
<com.myView
android:id="@+id/account_avatar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/account_menu_header_signed_in_avatar_margin_start"
android:layout_marginEnd="@dimen/account_menu_header_signed_in_avatar_margin_end"
android:layout_marginLeft="@dimen/account_menu_header_signed_in_avatar_margin_start"
android:layout_marginRight="@dimen/account_menu_header_signed_in_avatar_margin_end"
android:contentDescription="@null"
app:imageViewSize="@dimen/account_menu_header_signed_in_disc_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<View
android:id="@+id/account_display_name_top_padding"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="@dimen/account_menu_name_and_display_vertical_padding"
android:background="@color/google_red50"
app:layout_constraintBottom_toTopOf="@id/account_display_name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/account_avatar"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/account_display_name"
style="@style/AccountDataDisplayName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/google_red100"
android:gravity="center_vertical"
android:includeFontPadding="false"
app:layout_constraintBottom_toTopOf="@+id/account_name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toEndOf="@+id/account_avatar"
app:layout_constraintTop_toTopOf="@+id/account_display_name_top_padding"
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintWidth_default="wrap"
tools:text="DisplayNameIssLongSoItShouldBeTruncatedAtSomePoint"/>
<TextView
android:id="@+id/account_name"
style="@style/AccountDataAccountName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/google_green100"
android:gravity="center_vertical"
android:includeFontPadding="false"
app:layout_constraintBottom_toBottomOf="@+id/account_name_bottom_padding"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toEndOf="@+id/account_avatar"
app:layout_constraintTop_toBottomOf="@+id/account_display_name"
app:layout_constraintWidth_default="wrap"
tools:text="emailisverylongaswellwewantittogettruncated@gmail.longdomain.com"/>
<View
android:id="@+id/account_name_bottom_padding"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="@dimen/account_menu_name_and_display_vertical_padding"
android:background="@color/google_red50"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/account_avatar"
app:layout_constraintTop_toBottomOf="@id/account_name"/>
</android.support.constraint.ConstraintLayout>
</merge>


The result was almost OK, but the textViews are going too up and too close to the Image view.



here is the new result overlapping the old ui:



enter image description here



Does anyone have an idea why? or how to solve this?



I have added margin left to the imageView but it didn't seem to change anything.







android layout android-linearlayout padding android-constraintlayout






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 13 '18 at 22:45









Elad BendaElad Benda

12.9k61186336




12.9k61186336












  • Why would you add a left margin to your ImageView if it's already too close to the TextViews?

    – TheWanderer
    Nov 13 '18 at 22:57

















  • Why would you add a left margin to your ImageView if it's already too close to the TextViews?

    – TheWanderer
    Nov 13 '18 at 22:57
















Why would you add a left margin to your ImageView if it's already too close to the TextViews?

– TheWanderer
Nov 13 '18 at 22:57





Why would you add a left margin to your ImageView if it's already too close to the TextViews?

– TheWanderer
Nov 13 '18 at 22:57












1 Answer
1






active

oldest

votes


















0














Try building a more parallel structure between the TextViews in the LinearLayout and the ones in the ConstraintLayout something like the following. Here I have used a FrameLayout to show the overlay better and took some liberties with sizes, but the concept holds for your layout. As you can see from the image, the TextViews line up precisely except for the final character which is different between the two sets of TextViews to give a visual of the overlay.



enter image description here



<FrameLayout 
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal">

<LinearLayout
android:layout_width="250dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="16dp"
android:paddingBottom="16dp">

<TextView
android:id="@+id/account_display_name"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginStart="16dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="DisplayName1" />

<TextView
android:id="@+id/account_name"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginStart="16dp"
android:layout_weight="1"
android:gravity="center_vertical|start"
android:includeFontPadding="false"
android:text="emailisvery1" />
</LinearLayout>

<android.support.constraint.ConstraintLayout
android:layout_width="500dp"
android:layout_height="match_parent">

<TextView
android:id="@+id/account_display_name2"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginStart="16dp"
android:gravity="center_vertical"
android:paddingTop="16dp"
android:text="DisplayName2"
app:layout_constraintBottom_toTopOf="@id/account_name2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_weight="1" />

<TextView
android:id="@+id/account_name2"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginStart="16dp"
android:gravity="center_vertical|start"
android:includeFontPadding="false"
android:paddingBottom="16dp"
android:text="emailisvery2"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/account_display_name2"
app:layout_constraintVertical_weight="1" />
</android.support.constraint.ConstraintLayout>
</FrameLayout>t>





share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290641%2fconverting-linear-layout-to-constraint-layout-results-in-view-too-left%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Try building a more parallel structure between the TextViews in the LinearLayout and the ones in the ConstraintLayout something like the following. Here I have used a FrameLayout to show the overlay better and took some liberties with sizes, but the concept holds for your layout. As you can see from the image, the TextViews line up precisely except for the final character which is different between the two sets of TextViews to give a visual of the overlay.



    enter image description here



    <FrameLayout 
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:orientation="horizontal">

    <LinearLayout
    android:layout_width="250dp"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingTop="16dp"
    android:paddingBottom="16dp">

    <TextView
    android:id="@+id/account_display_name"
    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:layout_marginStart="16dp"
    android:layout_weight="1"
    android:gravity="center_vertical"
    android:text="DisplayName1" />

    <TextView
    android:id="@+id/account_name"
    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:layout_marginStart="16dp"
    android:layout_weight="1"
    android:gravity="center_vertical|start"
    android:includeFontPadding="false"
    android:text="emailisvery1" />
    </LinearLayout>

    <android.support.constraint.ConstraintLayout
    android:layout_width="500dp"
    android:layout_height="match_parent">

    <TextView
    android:id="@+id/account_display_name2"
    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:layout_marginStart="16dp"
    android:gravity="center_vertical"
    android:paddingTop="16dp"
    android:text="DisplayName2"
    app:layout_constraintBottom_toTopOf="@id/account_name2"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_weight="1" />

    <TextView
    android:id="@+id/account_name2"
    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:layout_marginStart="16dp"
    android:gravity="center_vertical|start"
    android:includeFontPadding="false"
    android:paddingBottom="16dp"
    android:text="emailisvery2"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@id/account_display_name2"
    app:layout_constraintVertical_weight="1" />
    </android.support.constraint.ConstraintLayout>
    </FrameLayout>t>





    share|improve this answer



























      0














      Try building a more parallel structure between the TextViews in the LinearLayout and the ones in the ConstraintLayout something like the following. Here I have used a FrameLayout to show the overlay better and took some liberties with sizes, but the concept holds for your layout. As you can see from the image, the TextViews line up precisely except for the final character which is different between the two sets of TextViews to give a visual of the overlay.



      enter image description here



      <FrameLayout 
      android:layout_width="match_parent"
      android:layout_height="100dp"
      android:orientation="horizontal">

      <LinearLayout
      android:layout_width="250dp"
      android:layout_height="match_parent"
      android:orientation="vertical"
      android:paddingTop="16dp"
      android:paddingBottom="16dp">

      <TextView
      android:id="@+id/account_display_name"
      android:layout_width="wrap_content"
      android:layout_height="0dp"
      android:layout_marginStart="16dp"
      android:layout_weight="1"
      android:gravity="center_vertical"
      android:text="DisplayName1" />

      <TextView
      android:id="@+id/account_name"
      android:layout_width="wrap_content"
      android:layout_height="0dp"
      android:layout_marginStart="16dp"
      android:layout_weight="1"
      android:gravity="center_vertical|start"
      android:includeFontPadding="false"
      android:text="emailisvery1" />
      </LinearLayout>

      <android.support.constraint.ConstraintLayout
      android:layout_width="500dp"
      android:layout_height="match_parent">

      <TextView
      android:id="@+id/account_display_name2"
      android:layout_width="wrap_content"
      android:layout_height="0dp"
      android:layout_marginStart="16dp"
      android:gravity="center_vertical"
      android:paddingTop="16dp"
      android:text="DisplayName2"
      app:layout_constraintBottom_toTopOf="@id/account_name2"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      app:layout_constraintVertical_weight="1" />

      <TextView
      android:id="@+id/account_name2"
      android:layout_width="wrap_content"
      android:layout_height="0dp"
      android:layout_marginStart="16dp"
      android:gravity="center_vertical|start"
      android:includeFontPadding="false"
      android:paddingBottom="16dp"
      android:text="emailisvery2"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toBottomOf="@id/account_display_name2"
      app:layout_constraintVertical_weight="1" />
      </android.support.constraint.ConstraintLayout>
      </FrameLayout>t>





      share|improve this answer

























        0












        0








        0







        Try building a more parallel structure between the TextViews in the LinearLayout and the ones in the ConstraintLayout something like the following. Here I have used a FrameLayout to show the overlay better and took some liberties with sizes, but the concept holds for your layout. As you can see from the image, the TextViews line up precisely except for the final character which is different between the two sets of TextViews to give a visual of the overlay.



        enter image description here



        <FrameLayout 
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:orientation="horizontal">

        <LinearLayout
        android:layout_width="250dp"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:paddingTop="16dp"
        android:paddingBottom="16dp">

        <TextView
        android:id="@+id/account_display_name"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_marginStart="16dp"
        android:layout_weight="1"
        android:gravity="center_vertical"
        android:text="DisplayName1" />

        <TextView
        android:id="@+id/account_name"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_marginStart="16dp"
        android:layout_weight="1"
        android:gravity="center_vertical|start"
        android:includeFontPadding="false"
        android:text="emailisvery1" />
        </LinearLayout>

        <android.support.constraint.ConstraintLayout
        android:layout_width="500dp"
        android:layout_height="match_parent">

        <TextView
        android:id="@+id/account_display_name2"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_marginStart="16dp"
        android:gravity="center_vertical"
        android:paddingTop="16dp"
        android:text="DisplayName2"
        app:layout_constraintBottom_toTopOf="@id/account_name2"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_weight="1" />

        <TextView
        android:id="@+id/account_name2"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_marginStart="16dp"
        android:gravity="center_vertical|start"
        android:includeFontPadding="false"
        android:paddingBottom="16dp"
        android:text="emailisvery2"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/account_display_name2"
        app:layout_constraintVertical_weight="1" />
        </android.support.constraint.ConstraintLayout>
        </FrameLayout>t>





        share|improve this answer













        Try building a more parallel structure between the TextViews in the LinearLayout and the ones in the ConstraintLayout something like the following. Here I have used a FrameLayout to show the overlay better and took some liberties with sizes, but the concept holds for your layout. As you can see from the image, the TextViews line up precisely except for the final character which is different between the two sets of TextViews to give a visual of the overlay.



        enter image description here



        <FrameLayout 
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:orientation="horizontal">

        <LinearLayout
        android:layout_width="250dp"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:paddingTop="16dp"
        android:paddingBottom="16dp">

        <TextView
        android:id="@+id/account_display_name"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_marginStart="16dp"
        android:layout_weight="1"
        android:gravity="center_vertical"
        android:text="DisplayName1" />

        <TextView
        android:id="@+id/account_name"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_marginStart="16dp"
        android:layout_weight="1"
        android:gravity="center_vertical|start"
        android:includeFontPadding="false"
        android:text="emailisvery1" />
        </LinearLayout>

        <android.support.constraint.ConstraintLayout
        android:layout_width="500dp"
        android:layout_height="match_parent">

        <TextView
        android:id="@+id/account_display_name2"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_marginStart="16dp"
        android:gravity="center_vertical"
        android:paddingTop="16dp"
        android:text="DisplayName2"
        app:layout_constraintBottom_toTopOf="@id/account_name2"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_weight="1" />

        <TextView
        android:id="@+id/account_name2"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_marginStart="16dp"
        android:gravity="center_vertical|start"
        android:includeFontPadding="false"
        android:paddingBottom="16dp"
        android:text="emailisvery2"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/account_display_name2"
        app:layout_constraintVertical_weight="1" />
        </android.support.constraint.ConstraintLayout>
        </FrameLayout>t>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 '18 at 0:00









        CheticampCheticamp

        28.3k42962




        28.3k42962





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290641%2fconverting-linear-layout-to-constraint-layout-results-in-view-too-left%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Use pre created SQLite database for Android project in kotlin

            Darth Vader #20

            Ondo