Android ConstraintLayout基线约束不可见

11

学习 ConstraintLayout 时遇到一个问题,即使选择了一个文本视图,基线约束手柄也不会变为可见状态。

使用的是 Android Studio 3.4.1,已选择 Show All Constraints

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'
}
2个回答

39
  1. 在可视化编辑器中选择所需的TextView。
  2. 右键单击它。
  3. 选择“显示基线”。

1
谢谢Kerbel。我想知道为什么我的编辑器悬停时没有给出那个选项。我的Studio版本是3.5。 - Dev.Sinto
有没有快捷键? - gouri panda

0

将鼠标悬停在可视化编辑器上,然后单击组件进行选择。您会看到一个“ab”按钮。单击它。


你说的只对于旧版本的Android Studio,新版本中你需要右键单击TextView并选择“显示基线”。 - Gabizon

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接