android-constraintlayout

How to `wrap_content` while autosizing an Android TextView?

廉价感情. 提交于 2019-12-11 07:18:55
问题 Consider this layout: <?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"> <TextView android:id="@+id/textView" android:layout_width="0dp" android:layout_height="0dp" android:layout_marginBottom="8dp" android:layout_marginEnd="8dp"

Infer Constraints in Android studio latest version(3.0)

别说谁变了你拦得住时间么 提交于 2019-12-11 06:48:41
问题 In this image there is a wiggy line to the button. Usually in the previous android version I used to select infer constraints so that the wiggy line gets disappeared. Now in the latest android version there is no option for infer constraints. Is there any other alternative to remove wiggy line? 回答1: You can use infer constraint in Android Studio 3.0 Just make sure you are in the "Design" tab and not the "Text" tab (seen near the bottom of the screen). Click on infer constraints 回答2: There IS

How to set width/margin of View programmatically relative another View within ConstraintLayout

我的未来我决定 提交于 2019-12-11 06:09:32
问题 I have a ConstraintLayout. For the purposes of this example, we can have three views inside. <android.support.constraint.ConstraintLayout ...> <TextView android:id="@+id/text" .../> <TextView android:id="@+id/value" .../> <View android:id="@+id/bar" android:layout_width="0dp" android:layout_height="8dp" android:background="@color/bar_color" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="@+id/text" app:layout_constraintEnd_toStartOf="@id/value" /> <

ConstraintLayout, RadioGroup and two columns of RadioButton

允我心安 提交于 2019-12-11 05:25:32
问题 I have a ConstraintLayout as a root Layout and it's fine. However I now have a RadioGroup where I have to make two columns of RadioButtons within it. Since ConstraintLayout is about getting the rid of Nested Layouts, I thought it would be fine placing those RadioButtons in the RadioGroup and place them appropriately. Turns out having a ConstraintLayout as a Root layout, Containing the RadioGroup, doesn't seem to change anything. But maybe I'm wrong. How would you guys achieve having two rows

Can the Android Flow virtual layout handle variable-width Views

倖福魔咒の 提交于 2019-12-11 04:49:06
问题 Android recently introduced Flow virtual layout but all of the examples I've seen show child Views that have the same width so it ends up laying out in a grid, instead of a jagged flow. I've seen variable width handles for flexbox-layout and Dhaval Solanki's FlowLayout. One other person asked a similar question (Which android layout to use for distributing variable width buttons to fill a screen?), but they were asking generally how to do it, whereas I'm asking specifically how to do it with

Constraint layout with child constraint layouts not expanding horizontally

 ̄綄美尐妖づ 提交于 2019-12-11 04:46:49
问题 I'm trying to build a rectangular view (spanning the width of the screen) which is split horizontally into three blocks, and I am doing so using a constraint layout. The left and right blocks have a specified width, but the centre block should expand to fit the remaining space. Because I require that the left-most block have a different background colour to the parent, I have grouped its children into another constraint layout. I have given the layout XML below: <?xml version="1.0" encoding=

ConstraintLayout with height wrap_content does not work with ImageView adjustViewBounds

断了今生、忘了曾经 提交于 2019-12-11 04:06:18
问题 I am trying to create this: And can do so with this LinearLayout: <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/white"> <ImageView android:id="@+id/image" android:src="@drawable/image" android:adjustViewBounds="true" android:layout_width="match_parent" android:layout_height="wrap_content" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout

Programmatically connecting multiple views set to any size using ConstraintLayout

*爱你&永不变心* 提交于 2019-12-11 03:39:11
问题 I'm using ConstraintLayout beta4 and trying to create a horizontal chain across the screen programmatically. The problem I'm running into is when I connect multiple views together in a chain across the screen (ex: Left side of layout <-> leftButton <-> rightButton <-> Right side of layout) then nothing shows up at all. Here is the code that does not work: public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate

Removing/Editing a constraint of a view inside a ConstraintLayout programmatically

*爱你&永不变心* 提交于 2019-12-11 03:16:58
问题 I have a view ( Linearlayout ) inside a ConstraintLayout with the following attributes: android:id="@+id/myView" app:layout_constraintTop_toBottomOf="@+id/anotherView" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" At some occasions I wish to align myView to the left, by simply removing the right constraint. however I'm not able to do so. I tried to use the following, simply to copy and apply the constraint parameters: ConstraintLayout.LayoutParams

Keep child view inside layout in ConstraintLayout

孤街浪徒 提交于 2019-12-11 03:16:20
问题 I have been trying to implement a bar showing progress data with ConstraintLayout. The problem is my TextView goes out of the layout bound when the Guideline is too left or too right of the bar. I have tried to change the constraints of the TextView from connected to the "@id/guideline" into "parent", and add horizontalBias instead, but then the TextView will become inaccurately positioned (a little shifted to right/left side depends on the yellow bar length) Here is the image of current