首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >ConstraintLayout自动将layout_width/layout_height添加到没有它的视图中

ConstraintLayout自动将layout_width/layout_height添加到没有它的视图中
EN

Stack Overflow用户
提问于 2016-10-18 22:04:04
回答 2查看 817关注 0票数 1

我在样式中定义了layout_width和layout_height,所以它实际上是设置的,但集成开发环境看不到我的样式,并使用android:layout_height="0dp“android:layout_width="0dp”自动完成我的代码。

代码示例:生成或在设计/文本集成开发环境之间切换时,添加到TextView android:layout_height="0dp“android:layout_width="0dp”

代码语言:javascript
代码运行次数:0
运行
复制
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<ImageView
    android:id="@+id/iv_contact_phone"
    android:layout_width="20dp"
    android:layout_height="20dp"
    android:layout_marginTop="15dp"
    android:src="@drawable/ic_phone"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintTop_toTopOf="parent" />


<TextView
    android:id="@+id/tv_contact_phone"
    style="@style/FormValue"
    android:layout_marginStart="16dp"
    android:layout_marginTop="16dp"
    app:layout_constraintLeft_toRightOf="@+id/iv_contact_phone"
    app:layout_constraintTop_toTopOf="parent" /></android.support.constraint.ConstraintLayout>

忘了提一下:

代码语言:javascript
代码运行次数:0
运行
复制
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9'
Androd Studio 2.2.1
EN

回答 2

Stack Overflow用户

发布于 2016-10-19 01:48:16

这听起来像是个bug --你能把它放到code.google.com上吗?谢谢!

票数 0
EN

Stack Overflow用户

发布于 2016-10-20 11:18:02

我发现了同样的问题,我发现添加android:layout_height="0dp“是因为为这个视图添加了visible="gone”,在我的例子中,删除它并以编程方式设置Visible工作,希望它能为你工作!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40110403

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档