android-constraintlayout

Simple yet tricky layout using ConstraintLayout

泪湿孤枕 提交于 2020-02-24 17:14:13
问题 I am trying to make the following seemingly simple yet tricky layout using ConstraintLayout . Normal UI: With longer title: I have tried following code: <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="16dp"> <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="end" android:maxLines="1" android:text="April Ludgate" android

ConstraintLayout with databinding

帅比萌擦擦* 提交于 2020-02-22 15:33:26
问题 Is it possible to do something like this: Xml: <android.support.constraint.Guideline app:layout_constraintGuide_percent="@{viewModel.guidelinePercent}" /> ViewModel: @Bindable public float getGuidelinePercent() { return condition ? 0.6f : 0.8f; } I'm getting this error: Cannot find the setter for attribute 'app:layout_constraintGuide_percent' with parameter type float on android.support.constraint.Guideline. I've tried with BindingAdaptor but it doesn't change the value: ViewModel:

Difference between ConstraintSet and ConstraintLayout.LayoutParams

纵然是瞬间 提交于 2020-02-08 10:17:21
问题 I have read through https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintLayout.LayoutParams I have also gone through various code examples, but I am unable to understand when does one need to use LayoutParams and when ConstraintSet. Link above says For building up constraints at run time, using ConstraintSet is recommended. The very fact that I am creating view programmatically means that I am defining constraints on run time. So I don't understand that line. I

Difference between ConstraintSet and ConstraintLayout.LayoutParams

自作多情 提交于 2020-02-08 10:16:31
问题 I have read through https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintLayout.LayoutParams I have also gone through various code examples, but I am unable to understand when does one need to use LayoutParams and when ConstraintSet. Link above says For building up constraints at run time, using ConstraintSet is recommended. The very fact that I am creating view programmatically means that I am defining constraints on run time. So I don't understand that line. I

Difference between ConstraintSet and ConstraintLayout.LayoutParams

蓝咒 提交于 2020-02-08 10:16:05
问题 I have read through https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintLayout.LayoutParams I have also gone through various code examples, but I am unable to understand when does one need to use LayoutParams and when ConstraintSet. Link above says For building up constraints at run time, using ConstraintSet is recommended. The very fact that I am creating view programmatically means that I am defining constraints on run time. So I don't understand that line. I

Adding constraints programmatically

℡╲_俬逩灬. 提交于 2020-02-01 02:44:26
问题 What is the translation to java code of the following XML instructions used in a layout definition with a constraint layout? app:layout_constraintBottom_toBottomOf="@+id/Button1" app:layout_constraintTop_toTopOf="@+id/Button1" app:layout_constraintLeft_toLeftOf="@+id/Button2" app:layout_constraintRight_toRightOf="Button2" 回答1: Here is an example of adding constraints programatically, ConstraintLayout mConstraintLayout = (ConstraintLayout)fndViewById(R.id.mainConstraint); ConstraintSet set =

Where is ConstraintLayout source code located?

烈酒焚心 提交于 2020-01-31 07:09:13
问题 Where can I find the source code for the android ConstraintLayout ? I can't find it in the support framework repository and even in Google search. 回答1: Its source code is here: https://android.googlesource.com/platform/frameworks/opt/sherpa/+/studio-3.0/constraintlayout/src/main/java/android/support/constraint/ConstraintLayout.java The Android SDK search extension adds a "View source" button on d.android.com reference, which helped me to get this link 来源: https://stackoverflow.com/questions

How do you add a ConstraintLayout to a LinearLayout in a ScrollView that fits the whole screen?

旧巷老猫 提交于 2020-01-25 10:20:09
问题 I want to be able to scroll through a LinearLayout, where each element is a ConstraintLayout that fits the whole screen. I've tried multiple values for layout_height in each Layout but nothing seems to be working. I could hardcode in a layout_height that fits my screen but that is not ideal. Here's what I currently have: <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools=

constraint layout - Two views with largest width

寵の児 提交于 2020-01-23 04:24:07
问题 I want to create a layout (using constraint layout) like the following: In different languages Button1 may be larger than button2. How can I do this? I've only been able to achieve this using a LinearLayout inside the constraint that contains the two buttons, but I'm trying to use only a layout. Thanks 回答1: I have seen questions akin to this one on Stack Overflow a number of times. These questions never have a satisfactory answer IMO (including ones that I have answered.) The difficulty is

what should i do to run this play again button, app crashes when its pressed(making a tic tac toe game)?

时光怂恿深爱的人放手 提交于 2020-01-22 03:31:25
问题 plz help me out in this problem i tried many changes that were suggested in android studio basically the problem occurs in playAgain function it crashes but it shold clear the images im the imageviews main activity package com.example.xo; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.GridLayout; import android.widget.ImageView; import android.widget.TextView; public class MainActivity