【发布时间】:2019-06-26 17:23:41
【问题描述】:
LinearLayout 中包含的 ConstraintLayout 中包含的 TextView 仅在 Android Studio 的预览窗口中可见。
TextView 被限制在父级的开始和顶部,所以它应该放在 View 的左上角。所有三个视图都设置为填充父级的大小。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<android.support.constraint.ConstraintLayout
android:id="@+id/view_downloads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"> <!-- default -->
<TextView
android:id="@+id/textview_downloads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAppearance="@android:style/TextAppearance.Material.Large"
android:visibility="visible"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Hello World!" />
</android.support.constraint.ConstraintLayout>
</LinearLayout>
我希望看到“Hello World!”放置在屏幕的左上角,如Preview window here 所示,但我看到的是一个空白视图,如this screenshot 所示,取自使用“空活动”项目模板和布局的最小示例如上所示。
【问题讨论】:
标签: android android-layout textview