我一直在想我的手ConstraintLayout,至今我都喜欢它了很多,除了现在我遇到了一个奇怪的问题.相同的布局,如果我使用a设计RelativeLayout显示包含的TextViews 的颜色作为默认文本颜色(灰色)但是ConstraintLayout,它显示白色.
这既发生在真实设备上,也发生在使用Android 5.0的仿真器上,而不是在仿真器(7.0)上.有谁知道,为什么会发生这种情况?
此外,明显的解决方案似乎是手动设计TextView布局中的颜色应该是什么,但这似乎是一个黑客而不是解决方案.我有兴趣知道,为什么这首先发生,如果这个黑客是唯一的解决方案?(我不想通过强制打开颜色来修复它,TextView因为Android 7.0 上的行为是正确的)
编辑:忘了提及布局编辑器将它们都显示为黑色/灰色,这也是一个实际颜色不应该是白色的提示.
供您参考,这里有2个布局是或多或少相同(有一个Button在其中之一,TextView而不是Button在其它),其中一个出现故障.
显示为白色的布局(焦点问题):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginRight="8dp"
android:layout_marginEnd="8dp"
android:background="@color/lightGrey">
<android.support.constraint.ConstraintLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:paddingBottom="10dp"
android:elevation="2dp"
android:id="@+id/constraintLayout">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/guideline"
android:layout_marginRight="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintHorizontal_bias="0.0"
android:id="@+id/linearLayout"
tools:layout_editor_absoluteY="16dp">
<TextView
android:text="@string/tutor_name"
android:textStyle="bold"
android:layout_width="match_parent" …Run Code Online (Sandbox Code Playgroud) 我正在尝试1.1.0-beta1中新的屏障功能.它按预期工作,但有这个用例我似乎无法计算或(或者可能是ConstraintLayout?)
我想要完成的是:我在左侧有一个图像视图,在图像视图右侧有标题和副标题文本视图.Imageview是固定的高度.我有一个按钮,底部约束到图像视图的底部, 但是如果subtitletextview比imageview高,则应该顶部约束到字幕文本视图的底部.
(顺便说一下,我也尝试将它的底部约束到imageview的底部,并将topconstrained到textview的底部并向底部赋予1.0偏向,但是对于大文本情况不起作用)
有障碍我只能将按钮顶部限制在障碍物的底部(或顶部,似乎相同)
<?xml version="1.0" encoding="utf-8"?>
<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="match_parent">
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@color/blue"/>
<ImageView
android:id="@+id/imageView4"
android:layout_width="0dp"
android:layout_height="150dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
android:scaleType="centerCrop"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/books"/>
<ImageView
android:id="@+id/imageView6"
android:layout_width="124dp"
android:layout_height="156dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView4"
app:srcCompat="@android:drawable/radiobutton_on_background"/>
<TextView
android:id="@+id/textView4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
android:text="TextView"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toRightOf="@+id/imageView6"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView4"/>
<TextView
android:id="@+id/textView5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Lorem Ipsum je fiktívny text, používaný pri návrhu tla?ovín a typografie. Lorem Ipsum je štandardným výpl?ovým textom už od …Run Code Online (Sandbox Code Playgroud)