android - ConstraintLayout: set height of all views in row to match the tallest one -


i'm trying utilize constraintlayout (version 1.0.2) set height of 2 side-by-side views match tallest 1 of them. serves viewholder in recyclerview, each textview gets arbitrary length of text...

if set each wrap_content, shorter 1 shrink. if set both 0dp (match_contraints), both end 0 height.

here's setup:

<?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_marginleft="2dp"     android:layout_marginright="2dp"     android:layout_width="match_parent"     android:layout_height="wrap_content">      <textview         android:id="@+id/id1"         android:layout_width="60dp"         android:layout_height="0dp"         app:layout_constrainttop_totopof="parent"         app:layout_constraintbottom_tobottomof="parent"         app:layout_constraintstart_tostartof="parent"         app:layout_constraintend_tostartof="@+id/id2"/>      <textview         android:id="@+id/id2"         android:layout_width="0dp"         android:layout_height="0dp"         app:layout_constrainttop_totopof="parent"         app:layout_constraintbottom_tobottomof="parent"         app:layout_constraintstart_toendof="@+id/id1"         app:layout_constraintend_toendof="parent"/>  </android.support.constraint.constraintlayout> 

i suppose bug, "0dp" should act more match_parent actual 0 dp.

on ios, way, equivalent auto layout rules (of setting views' heights match top , bottom of parent) produce expected result.

of course pretty simple using linearlayout, layout plays part in larger layout, , i'd trim view hierarchy...

this might you.

<android.support.constraint.constraintlayout         android:id="@+id/activity_main"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:paddingbottom="@dimen/activity_vertical_margin"         android:paddingleft="@dimen/activity_horizontal_margin"         android:paddingright="@dimen/activity_horizontal_margin"         android:paddingtop="@dimen/activity_vertical_margin">          <textview             android:id="@+id/tv_1"             android:layout_width="150dp"             android:layout_height="match_parent"             android:layout_marginend="8dp"             android:layout_marginright="8dp"             android:background="@color/coloraccent"             android:gravity="center"             android:padding="@dimen/activity_vertical_margin"             android:text="sjdjhshdjhdjhsdgfjhgsdjfgjsdgfjsdgfhgdsjhfghs"             app:layout_constraintbottom_tobottomof="parent"             app:layout_constraintleft_toleftof="parent"             app:layout_constraintright_toleftof="@+id/tv_2"             app:layout_constrainttop_totopof="parent" />          <textview             android:id="@+id/tv_2"             android:layout_width="150dp"             android:layout_height="match_parent"             android:background="@color/colorprimary"             android:gravity="center"             android:padding="@dimen/activity_vertical_margin"             android:text="sjdjhsjhd"             app:layout_constraintbottom_tobottomof="parent"             app:layout_constraintleft_torightof="@+id/tv_1"             app:layout_constraintright_torightof="parent"             app:layout_constrainttop_totopof="parent" />      </android.support.constraint.constraintlayout> 

enter image description here

enter image description here


Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -