# constraintlayout

ConstraintLayout is an Android layout manager that flexibly positions and sizes widgets, available for the Android view system and Jetpack Compose.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## CatGPT - or How to Position Elements on Overlays

DevFeed: [CatGPT - or How to Position Elements on Overlays](<https://devfeed.tech/articles/catgpt-or-how-to-position-elements-on-overlays-38464.md>)

Original publisher: [Read original article](<https://eevis.codes/blog/2023-10-22/catgpt-or-how-to-position-elements-on-overlays/>)

Author: Eevis Panula

Published: 2023-10-22T06:55:09.601000Z

Content type: tutorial

Language: en

Sources: [Eevis Blog](<https://devfeed.tech/sources/eevis-blog.md>)

Topics: [constraintlayout](<https://devfeed.tech/topics/constraintlayout.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [constraintlayout](<https://devfeed.tech/tags/constraintlayout.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [ui-components](<https://devfeed.tech/tags/ui-components.md>)

### AI overview

A tutorial showing how to position a reaction element as an overlay on a message in a Kotlin chat client. It demonstrates using a ConstraintLayout, references, and modifiers to anchor the reaction in the message component.

### Source excerpt

Have you ever wondered how to display an element with an overlay while keeping it in the same position? The same way that, for example, many messaging apps highlight the message you want to react to. I had this type of challenge in one of my work projects. It took some trial and error to get it working, but I was so proud of myself when I finally found the correct modifiers (and numbers). I want to share one way to do it with you in this blog post. The Example App Okay, I must say that I maybe, just maybe, got a little bit carried away with this example app. But it's a CatGPT - a chat client where you can ask anything from a cat. Here's a short video: This app is simple; It doesn't use any third-party APIs, so the cat in question lives in the code. The app has one Room database, where it stores messages, and it has one screen called ChatScreen which displays messages. If you want to see the code, the starting point for the app is in the starting-point-branch, and the final code is in CatGPT-repository's main-branch. Showing Reaction with Message To simplify this app, each message can have only one reaction. In the Message data class, the reaction is already present: // data/Message.kt @Entity data class Message( @PrimaryKey(autoGenerate = true) val id: Long = 0, val text: String = "", val sender: Sender = Sender.ME, @TypeConverters(ReactionConverter::class) val reaction: Reaction? = null, ) And it's a nullable Reaction-enum. The complete code and converters for Reaction are in Message.kt. Let's first add code for showing that reaction before building the actual reaction picker. In the MessageRow.kt-file, there is already a ConstraintLayout, which contains the component for the message. We want to show the reaction in the bottom right corner of that component, so we'll add the reaction inside the constraint layout. The component for reaction looks like this: // ui/components/MessageRow.kt message.reaction?.let { Text( modifier = Modifier .clip(ChatScreen.shape) .back

## Controlling TextView MinWidth

DevFeed: [Controlling TextView MinWidth](<https://devfeed.tech/articles/controlling-textview-minwidth-38652.md>)

Original publisher: [Read original article](<https://krossovochkin.com/posts/2021_09_14_controlling_textview_minwidth/>)

Published: 2021-09-14T00:00:00Z

Content type: tutorial

Language: en

Sources: [Vasya Drobushkov](<https://devfeed.tech/sources/vasya-drobushkov.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [constraintlayout](<https://devfeed.tech/topics/constraintlayout.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-layout](<https://devfeed.tech/tags/android-layout.md>), [background](<https://devfeed.tech/tags/background.md>), [constraintlayout](<https://devfeed.tech/tags/constraintlayout.md>), [gravity](<https://devfeed.tech/tags/gravity.md>), [layout](<https://devfeed.tech/tags/layout.md>), [properties](<https://devfeed.tech/tags/properties.md>), [textview](<https://devfeed.tech/tags/textview.md>), [xml](<https://devfeed.tech/tags/xml.md>)

### AI overview

A technical explanation of how Android TextView minimum-width APIs interact. Setting minWidth or minimumWidth alone may not reset a dimension declared in XML; both properties must be cleared, and a background can still impose a minimum width.

### Source excerpt

Introduction Sometimes we might need our TextView with wrap_content width to occupy more space than it will based on amount of characters it displays. For that we can set minimum width. Usually, we do that via XML like this: <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.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=".MainActivity"> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/bg_text" android:gravity="center" android:minWidth="200dp" android:text="Hello World!" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout> Having setup like this we ensure that our TextView will occupy a minimum of 200dp. Also, we can control minimum width programmatically via: TextView#setMinWidth. But controlling minimum width programmatically has one caveat that I'd like to describe below.

## Android's ConstraintLayout: Align One View's Edge to Another View's Center

DevFeed: [Android's ConstraintLayout: Align One View's Edge to Another View's Center](<https://devfeed.tech/articles/android-s-constraintlayout-align-one-view-s-edge-to-another-view-s-center-29111.md>)

Original publisher: [Read original article](<https://www.grokkingandroid.com/align-one-views-edge-to-another-views-center-in-constraintlayout/>)

Author: Wolfram Rittmeyer

Published: 2016-08-30T07:20:07Z

Content type: tutorial

Language: en

Sources: [Grokking Android](<https://devfeed.tech/sources/grokking-android.md>)

Topics: [constraintlayout](<https://devfeed.tech/topics/constraintlayout.md>), [Android](<https://devfeed.tech/topics/android.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [constraintlayout](<https://devfeed.tech/tags/constraintlayout.md>), [layout](<https://devfeed.tech/tags/layout.md>)

### AI overview

A tutorial explains how to align one Android view's edge with the center of another in ConstraintLayout when no direct constraint attribute is available. It uses a centered, invisible helper view and aligns the second view to that helper.

### Source excerpt

As you can see from the following excerpt of ConstraintLayout's supported attributes, there is no layout_constraintStart_toCenterX attribute. Thus you cannot directly align the left edge of one view to the center of another view. But ConstraintLayout is flexible enough to get your view aligned to the center of another view without such an attribute. Even [...] Continue Reading "Android's ConstraintLayout: Align One View's Edge to Another View's Center" The post Android's ConstraintLayout: Align One View's Edge to Another View's Center appeared first on Grokking Android.

## Some Thoughts on Android's new ConstraintLayout and Android Studio's new Design Editor

DevFeed: [Some Thoughts on Android's new ConstraintLayout and Android Studio's new Design Editor](<https://devfeed.tech/articles/some-thoughts-on-android-s-new-constraintlayout-and-android-studio-s-new-design-editor-29125.md>)

Original publisher: [Read original article](<https://www.grokkingandroid.com/thoughts-on-constraintlayout-and-design-editor/>)

Author: Wolfram Rittmeyer

Published: 2016-07-06T06:10:42Z

Content type: opinion

Language: en

Sources: [Grokking Android](<https://devfeed.tech/sources/grokking-android.md>)

Topics: [constraintlayout](<https://devfeed.tech/topics/constraintlayout.md>), [Android Studio](<https://devfeed.tech/topics/android-studio.md>), [Android](<https://devfeed.tech/topics/android.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-studio](<https://devfeed.tech/tags/android-studio.md>), [constraintlayout](<https://devfeed.tech/tags/constraintlayout.md>), [layout](<https://devfeed.tech/tags/layout.md>), [layout-editor](<https://devfeed.tech/tags/layout-editor.md>), [work](<https://devfeed.tech/tags/work.md>)

### AI overview

An opinion article examines Android's ConstraintLayout and Android Studio's redesigned Design Editor. It highlights easier handling of complex screen designs, stretched child dimensions, guidelines, and the intended performance improvements, while noting that the layout was still in alpha and required further work.

### Source excerpt

At this year's IO Google introduced a new layout - the ConstraintLayout - and also presented it's totally revamped layout editor. I am not going into how to use the layout. Google itself has done a good job in explaining it with its code lab "Using ConstraintLayout to design your views". In this post I [...] Continue Reading "Some Thoughts on Android's new ConstraintLayout and Android Studio's new Design Editor" The post Some Thoughts on Android's new ConstraintLayout and Android Studio's new Design Editor appeared first on Grokking Android.