android-constraintlayout

Change Guideline percentage in constraint layout programmatically

孤人 提交于 2019-12-20 15:44:37
问题 I have a guideline in constraint layout like this <android.support.constraint.Guideline android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/guideline8" app:layout_constraintGuide_percent="0.5" android:orientation="vertical"/> Later I want to change the app:layout_constraintGuide_percent value to something else conditionally. How can I achieve this. 回答1: There is two ways to do it: Using ConstraintLayout.LayoutParams This method get a specific parameter

ConstraintLayout Treats Multiple Horizontal Chains Differently

我的梦境 提交于 2019-12-20 07:36:03
问题 I am attempting to set up what I thought should be a simple layout with a ConstraintLayout I have a series of text entries, with labels whose size can change from language to language. There is a barrier to the right side of the labels so the text entries stay aligned even when the label lengths change. I want the text entries to be a nominal size (200dp for the top one and 150dp for the others in this example) but to be able to shrink as needed to fit the screen if the labels are long and

Barrier doesn't set to referenceIds in constraint layout?

一世执手 提交于 2019-12-20 05:01:35
问题 hey last few days I am exploring about the constraint layout.the concept of barrier I can understand but when i implement I can't get the correct output. I want to set the barrier in the right direction to reference Id's. But barrier doesn't work.it should set for the views which are nameLabel and passionLabel. please help me. thank you in advance. This is the current output <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas

Is it possible to scroll a ScrollView with a ConstraintLayout in Blueprint Mode?

心不动则不痛 提交于 2019-12-19 13:08:55
问题 So I have been developing this layout using a ConstraintLayout inside a ScrollView. It works fine, but now I have hit a problem. I have to expand the layout outside the screen. I can scroll in Design mode, but I cannot add anything without it getting stuck to the top. The constraints are for earlier objects, not the current one I'm adding. I can add constraints in Blueprint mode, but it looks like I cannot scroll the ScrollView in blueprint mode. Is this even possible? Using Android Studio 2

toggle visibility of chain group in constraint layout

允我心安 提交于 2019-12-19 05:07:07
问题 In previous xml layout, I have multiple view groups with few elements inside. Hide each view group will also hide all of its child elements. Since I wanted to have flat structure and tried ConstraintLayout . Cool I know how to chain element with spread to align properly. Since flat structure does not have wrapped LinearLayout , now i have 3 views to hide instead. I would like to know if there is alternative to achieve this. Without constraint layout <RelativeLayout.... .......... ..........

Group views in ConstraintLayout to treat them as a single view

不问归期 提交于 2019-12-18 11:46:34
问题 I need to apply some constraints to a group of views in ConstraintLayout. I want to group these views and continue editing while the layout designer in Android studio treats them as a single view. Is there a way to do so without actually wrapping the views with a ViewGroup (another layout)? If such a wrapper is necessary, maybe there is a wrapper layout that comes with ConstraintLayout and allows to group objects without creating heavy layouts like RelativeLayout ? 回答1: ConstraintLayout

make RecyclerView's height to “wrap_content” in Constraint layout

北城以北 提交于 2019-12-18 10:53:29
问题 i'm trying to set the height of recycler view on wrap_content and make it respect that,but it will exceed the other widget on layout. what can i do now? <android.support.constraint.ConstraintLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/white"> <TextView android:id="@+id/tvPastRounds" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginLeft="16dp" android:layout_marginTop="0dp" android:text="Past

What is difference between Barrier and Guideline in Constraint Layout?

醉酒当歌 提交于 2019-12-18 10:11:32
问题 Recently trying to implement Constraint Layout but I found Barrier and Guideline works same. Both works like divider. Is there any difference between them? 回答1: When to use barriers Assume you have two TextView widgets with dynamic heights and you want to place a Button just below the tallest TextView : The ONLY way to implement that directly in the layout is to use a horizontal Barrier . That Barrier allows you to specify a constraint based on the height of those two TextView s. Then you

Android add other layout in ConstraintLayout using include tag

心不动则不痛 提交于 2019-12-18 05:27:06
问题 I make some simple app for test using ConstraintLayout. But I have some problem. Here is my code activity_main.xml <?xml version="1.0" encoding="utf-8"?> <layout 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.support.constraint.ConstraintLayout android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.user.myapplication.activity

ConstraintLayout: how to have a view be half the screen width and centered?

拈花ヽ惹草 提交于 2019-12-18 03:53:55
问题 TD;DR The view width must be exactly the half of the screen, and be centered. Using ConstraintLayout. Note that the view does not have any inner width. <View android:background="#ff0000" ... /> Original question I would like to achieve a layout where a view size is half the screen size, and centered horizontally. Something like this: |--view--| I can't find any way using ConstraintLayout. The best i found is by using app:layout_constraintHorizontal_weight="1" on 2 fake views positioned at the