[英]Can't see anything on Android Studio preview and device
I'm trying to follow a tutorial, and everything works. 我正在尝试按照教程进行操作,一切正常。 However, I can't get the view part.
但是,我无法获得视图部分。 When I copy the xml file it should show the placeholder text for the TextView, but nothing happens.
当我复制xml文件时,它应该显示TextView的占位符文本,但是什么也没有发生。 I'm not receiving errors, and if i manually drag the textview it appears, but using match parent does not.
我没有收到错误,并且如果我手动拖动textview会出现,但是使用match parent不会。
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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:layout_margin="16dp"
tools:context=".MainActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
<!-- Contains the list of all sensors, generated in onCreate(). -->
<TextView
android:id="@+id/sensor_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/placeholder_text"
android:visibility="visible"
tools:visibility="visible" />
</ScrollView>
我不认为匹配父项有问题,只是您的约束视图没有关闭标签,添加后就可以正常显示了
</androidx.constraintlayout.widget.ConstraintLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.