Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ConstraintLayout baseline constraint not visible

Learning ConstraintLayout and running into this issue where the baseline constraint handle does not become visible even as a text view is selected.

Using Android Studio 3.4.1, Show All Constraints is selected.

enter image description here

gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
    applicationId "com.example.myapplication"
    minSdkVersion 28
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
like image 838
kmansoor Avatar asked May 26 '19 18:05

kmansoor


People also ask

What is baseline in constraint layout?

A baseline is a horizontal invisible line that is centered in a view. A view can only have one baseline used to align it horizontally. To add a baseline, right-click on the view that you want to align the baseline to that of another view. Select show baseline .

How many constraint handles are available to us as part of the ConstraintLayout?

The TextView above has three types of handles: Resize handle - It's present on the four corners and is used to resize the view, but keeping its constraints intact. Side handle - It's the circular handle present on the centre of each side. It's used to set the top, left, bottom and right constraints of the view.

Is ConstraintLayout faster than LinearLayout?

More complex layout but results are the same, flat Constraint Layout is slower than nested Linear Layout. I want to pay attention to 2 more things which are more subjective. Creating Constraint Layout takes more time than other layouts. Also introducing changes in existing Constraint Layout is much more time-consuming.

How do I change ConstraintLayout to LinearLayout?

Open the layout file (activity_main. xml) in Android Studio and click the Design tab at the bottom of the editor window. In the Component Tree window, right-click LinearLayout and then choose Convert layout to ConstraintLayout from the context menu.


1 Answers

  1. In the visual editor select the wanted TextView.
  2. Right-click on it.
  3. Select "Show Baseline"
like image 139
Itamar Kerbel Avatar answered Sep 28 '22 21:09

Itamar Kerbel