android xml not taking into account margins on custom layouts - android

This is my custom view (custom_view.xml): *Note that I define 3 margins on the CardView.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView 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="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:background="#color/white"
android:orientation="vertical"
app:cardCornerRadius="4dp"
app:cardElevation="0dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="16dp"
android:background="#color/white">
<ImageView
android:id="#+id/left_image"
android:layout_width="64dp"
android:layout_height="40dp"
android:layout_marginTop="5dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="#id/left_image"
android:layout_toLeftOf="#+id/right_image"
android:layout_toRightOf="#id/left_image"
android:layout_toStartOf="#id/right_image"
android:orientation="vertical">
<com.ringapp.ui.view.TypefaceTextView
android:id="#+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<com.ringapp.ui.view.TypefaceTextView
android:id="#+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<ImageView
android:id="#id/right_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginTop="5dp"
android:src="#drawable/icon_md_gray_arrow" />
</RelativeLayout>
</android.support.v7.widget.CardView>
I add the custom layout on the following xml (container.xml):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:orientation="vertical">
<com.ringapp.ui.view.CustomView
android:id="#+id/test2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
app:description="edsc"
app:title="title" />
<com.ringapp.ui.view.CustomView
android:id="#+id/test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
app:description="asdasd"
app:title="asdasdasd" />
</LinearLayout>
The problem is that the margins that I defined on the custom_view.xml doesn't appear on the container.xml layout. Why is this happening? If I paste the code of custom_view.xml directly on container.xml the margins appears.

Instead of
<com.ringapp.ui.view.CustomView
android:id="#+id/test2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Try this:
<include layout="#layout/custom_view" android:id="#+id/test2/>
I believe when you use the code you have, android tries to over right some of your view's properties, especially when you explicitly overwrite the layout width / height. Try the above line of code in place of yours. Also, no need to overwrite the layout width / height if you're just going to wrap content, as the layout dimensions will be brought over from your custom_view.
Edit: To clarify, your code would probably even work if you took out the layout width / height overwrites. But you should use includes when bringing other XML layouts into a different XML layout. The way you 'included' your view is fine, but should probably be used fro when you write custom view classes that extend android 'View'.

Related

Multiline text view not showing the full text

I have the following layout with a LinearLayout that contains a Material ShapableImageView and a TextView. I need my TextView to take 2 lines if it's width is bigger than the ImageView's with, but I can't figure out how to do it.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/company_card_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:foreground="?attr/selectableItemBackground"
android:orientation="vertical"
android:paddingStart="#dimen/padding_small"
android:paddingEnd="#dimen/padding_small"
android:paddingBottom="#dimen/padding_small">
<com.google.android.material.imageview.ShapeableImageView
android:id="#+id/category_logo"
android:layout_width="120dp"
android:layout_height="96dp"
android:layout_gravity="center_horizontal"
android:scaleType="centerCrop"
android:src="#drawable/ic_avatar_default_tinted"
app:shapeAppearanceOverlay="#style/AppTheme.ShapeableImageView.Squircle" />
<TextView
android:id="#+id/category_name"
style="#style/AppTheme.Text.Caption.Light.Darker"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:maxLines="2"
android:textStyle="bold"
tools:text="This is a very long text and should take at least 2 lines" />
</LinearLayout>
This is how it's currently being shown and as you can see, it doesn't show the full text:
Seeing that you're limiting the width of your LinearLayout by the width of your image, you can set its width to the same, which should help. This allows the measure pass (I believe) to "better" define all the measure constraints/rules.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/company_card_layout"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.google.android.material.imageview.ShapeableImageView
android:id="#+id/category_logo"
android:layout_width="120dp"
android:layout_height="96dp"
android:layout_gravity="center_horizontal"
android:scaleType="centerCrop"
android:src="#drawable/my_drawable" />
<TextView
android:id="#+id/category_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="This is a very long text and should take at least 2 lines" />
</LinearLayout>

How to align buttons next to text that should flow on 2 lines?

So I want to have a title with 2 buttons next to it. These buttons should stick to the left next to the text, and when the text becomes too long, it should flow on 2 lines.
I was able to replicate this by giving the textView a maxwidth, but this causes the textview to take that maxwidth, even if it reflows on 2 lines. Therefore my buttons don't align next to the text anymore.
Like this:
How can I make my textView take the width it needs, not the one I tell it to use as maxWidth?
Here comes the perfectly working answer using ConstraintLayout (as I love this layout).
This is the code.
<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.support.constraint.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/text"
android:layout_marginTop="25dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:maxWidth="300dp">
<TextView
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:maxWidth="300dp"
android:text="Some layout is going to be created and whatever I do it won't cross the limit."
android:textSize="30sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"/>
</android.support.constraint.ConstraintLayout>
<ImageView
android:layout_height="40dp"
android:background="#365987"
android:layout_width="40dp"
android:layout_marginStart="5dp"
android:id="#+id/image"
app:layout_constraintLeft_toRightOf="#+id/text"
app:layout_constraintTop_toTopOf="#+id/text"/>
<ImageView
android:id="#+id/image1"
android:layout_height="40dp"
android:background="#e85f11"
android:layout_width="60dp"
android:layout_marginStart="5dp"
app:layout_constraintBottom_toBottomOf="#+id/image"
app:layout_constraintLeft_toRightOf="#+id/image"
app:layout_constraintTop_toTopOf="#+id/image"/>
</android.support.constraint.ConstraintLayout>
Outputs:
Whatever the text is, it will not cross the maxwidth. And with less width than maxwidth, it's width will be wrap_content.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/tv_male"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="15dp"
android:text="Male:"
android:textColor="#111111"
android:textSize="12dp" />
<ImageView
android:id="#+id/iv_male"
android:layout_width="#dimen/_42sdp"
android:layout_height="#dimen/_42sdp"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:padding="10dp"
android:src="#drawable/block_user" />
<ImageView
android:id="#+id/iv_female"
android:layout_width="#dimen/_42sdp"
android:layout_height="#dimen/_42sdp"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:padding="10dp"
android:src="#drawable/blocked_user" />
</LinearLayout>
<TextView
android:id="#+id/tv_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is something Demo Content"
android:layout_marginLeft="#dimen/_15sdp"
android:textColor="#111111"
android:textSize="12dp" />
</LinearLayout>
So you can just add content below the linear layout complete
I Hope it Helps you and you will get your solution.
Try this code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/zero"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="2"
android:paddingEnd="100dp"
android:text="Simple textdfddfdf dfdfdfdfdf dfdf Sample Text Sample Text" />
<LinearLayout
android:id="#+id/one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/zero"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#mipmap/ic_launcher" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#mipmap/ic_launcher" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
Here, You have to pass android:paddingEnd="100dp". This you can manage from dimens.xml
I hope. This will help full
You should use ConstraintLayout
compile 'com.android.support.constraint:constraint-layout:1.0.2'
Let's take an instance of that Planner part of the image.
<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/constraintLayout"
<!-- Other attributes -->
<TextView
android:id="#+id/text"
android:layout_width = "xxxdp"
android:layout_height = "xxxdp"
app:layout_constraintBottom_toBottomOf="#+id/constraintLayout"
app:layout_constraintLeft_toLeftOf="#+id/constraintLayout"
app:layout_constraintTop_toTopOf="#+id/constraintLayout"
<!-- Other attributes --> />
<ImageView
android:id="#+id/image1"
app:layout_constraintBottom_toBottomOf="#+id/text"
app:layout_constraintLeft_toRightOf="#+id/text"
app:layout_constraintTop_toTopOf="#+id/text"
<!-- Other attributes --> />
<ImageView
android:id="#+id/image1"
app:layout_constraintBottom_toBottomOf="#+id/text"
app:layout_constraintLeft_toRightOf="#+id/image1"
app:layout_constraintTop_toTopOf="#+id/image1"
<!-- Other attributes --> />
Definition of Attributes used.
layout_constraintTop_toTopOf — Align the top of the desired view to the top of another.
layout_constraintBottom_toBottomOf — Align the bottom of the desired view to the bottom of another.
layout_constraintLeft_toRightOf — Align the left of the desired view to the right of another.

Responsive layout on Android

I have three elements in layout, two TextViews and one ImageView between them. I'm trying to achieve this behavior:
image (arrow) has 9patch
image is wide as possible
image has set minimal width
right and left texts go wider with longer text but only to meet image's minWidth, then new line appears
Below are few screenshots from Android Studio layout preview, gained with different layouts.
What I have tried:
Relative layout: image centered, minWidth set, texts have set toRightOf/toLeftOf
Relative layout: image has set toRightOf/toLeftOf
Constraint layout: "constraint arrows" go from image to text
Constraint layout: "constraint arrows" go from text to image
Linear layout: using weight (not really responsive)
What I always get:
What I want seems quite straightforward to me but I cannot do it. Am I missing something or is it really impossible? Thank you in advance.
Use below code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/left_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="TextView" />
<ImageView
android:id="#+id/imageView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="100dp"
android:layout_toLeftOf="#+id/right_tv"
android:layout_toRightOf="#+id/left_tv"
app:srcCompat="#drawable/arrow" />
<TextView
android:id="#+id/right_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="TextView" />
</RelativeLayout>
Replace your image with arrow
Here is one more answer done via constraintLayout by creating horizontal chains.
Updated as you asked
<?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="wrap_content">
<TextView
android:id="#+id/left_tv"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="ajn sdhbch chf nbhjgvbf vkjf vhf bvihfijnvj vfknvv ihvb jnvkjnfv kjnvfn"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="#+id/imageView6"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/imageView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="#+id/left_tv"
app:layout_constraintRight_toLeftOf="#+id/right_tv"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_next_button" />
<TextView
android:id="#+id/right_tv"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="#+id/imageView6"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
Updated: the code is updated for more responsive layout.
Now play with maxwidth of both text views.
For your problem updating maxwidth programmatically will be better.
This code is done with Linear layout method. There is a GridLayout method also along with constraintLayout method. Can be achieved with many layouts, if you know the right technique to do so.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:id="#+id/left_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView is long and very long" />
<ImageView
android:id="#+id/imageView6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="#drawable/ic_add_circle_green" />
<TextView
android:id="#+id/right_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxWidth="60dp"
android:text="TextView is long and very long" />
</LinearLayout>

Android: Change CardView Layout on Orientation Change

So I've spent a day on this one and it's time to turn to the pros on StackOverflow.
I am working with RecyclerView and CardView to display cards that contain text and an image. In portrait it looks great but in landscape there is space on both sides of the image instead of being flush with the edge of the card. I cannot change the dimensions of the image so I would like to change the XML of the CardView on orientation change, like you can do with a Fragment or Activity.
Is this possible and how could this be implemented? The only thought I have now would be to have another ViewHolder inside of my RecyclerViewAdapter that is used when checking for orientation returns Landscape. I'm hoping for a simpler solutions. Thanks in advance guys.
CardView XML. Notice that the width of the card is set to match_parent.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/tools"
android:id="#+id/placeCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
card_view:cardCornerRadius="4dp"
card_view:cardElevation="8dp"
android:background="#drawable/ripple"
android:clickable="true"
android:focusable="true"
android:foreground="?selectableItemBackground">
<RelativeLayout
android:id="#+id/rippleForeground"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/articleImageView"
android:layout_width="match_parent"
android:layout_height="228dp" />
<RelativeLayout
android:id="#+id/infoRelativeLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/paletteView"
android:background="#android:color/white"
android:paddingRight="8dp"
android:paddingBottom="8dp"
android:paddingLeft="8dp">
<TextView
android:id="#+id/titleTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="8dp"
android:text="#string/placeholder"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<TextView
android:id="#+id/abstractTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/titleTextView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="8dp"
android:text="#string/placeholder" />
<!--<TextView
android:id="#+id/timeTextView"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="#string/placeholder"
android:textColor="#color/colorSecondaryText"/>-->
<TextView
android:id="#+id/globalTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/abstractTextView"
android:layout_alignParentBottom="true"
android:padding="8dp"
android:gravity="center"
android:text="#string/placeholder"
android:textStyle="bold"
android:textColor="#color/colorSecondaryText"/>
</RelativeLayout>
<View
android:id="#+id/paletteView"
android:layout_width="match_parent"
android:layout_below="#id/articleImageView"
android:layout_height="4dp"
android:layout_marginTop="12dp"/>
</RelativeLayout>
Add a layout_land folder in res and copy your xml to it.You will use xml in this folder if your orientation is Landscape.You can change the xml in this folder to fit.
You can scale the image in the xml like this:
<ImageView
android:id="#+id/articleImageView"
android:layout_width="match_parent"
android:layout_height="228dp"
android:scaleType="fitXY" />

Put a button over an ImageView

I'm newbie in Android.
I would like to know if it's possible to put a button or another component over an ImageView. I've tried setting the image as a background image of a LinearLayout, but when I change between landscape and portrait mode, the image porportions are changed.
Thanks a lot.
Don't put the image as a background, you don't have any control on how the image is scaled. Instead, create a RelativeLayout, and put an ImageView as one of the child, and you can place anything (buttons etc) as other RelativeLayout children.
<RelativeLayout ...>
<ImageView (your image) ...>
<Button (the button you want) ... />
</RelativeLayout>
Try this code... it's Help you....
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/imageviewMain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="Path "
/>
<Button android:id="#+id/but2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
Try this Code .....
In that give paramater in button to set your Button Position....
android:layout_margin or android:layout_alignParent
And also give Path of Image....
There is another way to do it,http://www.curious-creature.org/2009/03/01/android-layout-tricks-3-optimize-part-1/
Thank you.
The simpliest way to do it is to use a FrameLayout.
This is easy using the ConstraintLayout.
Set the constraints of the Button to the ImageView.
Drag the Button anywhere you want over the ImageView to position it.
XML code will be autogenerated.
For those using Constraint Layout: Just use an ImageView and add its constraints from all the four side to Parent and than add the other views as well.
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
app:cardCornerRadius="10dp"
app:cardElevation="10dp"
app:cardPreventCornerOverlap="true"
app:contentPadding="5dp"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/food"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="#+id/imagebtn_share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_share_24"
app:layout_constraintTop_toTopOf="parent"
android:padding="15dp"
app:layout_constraintStart_toStartOf="parent" />
<ImageButton
android:id="#+id/imagebtn_call"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_call_24"
android:padding="15dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<TextView
android:id="#+id/expdate_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/test_date"
android:background="#E2E3E4"
android:layout_marginBottom="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="#+id/imagebtn_address"
android:layout_marginEnd="30dp"
android:padding="5dp"/>
<TextView
android:id="#+id/title_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginBottom="5dp"
android:background="#E2E3E4"
android:padding="5dp"
android:textSize="18sp"
android:text="#string/test_foodname"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/imagebtn_address"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent" />
<ImageButton
android:id="#+id/imagebtn_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_location_on_24"
android:padding="15dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
Note: Replace the drawables added with your own.

Categories

Resources