android-TextView不见了,Button是可见的

Textview项目不可见.它们下面的按钮是.

尝试使用RelativeLayout更改LinearLayout,将match_parent和content更改为0dp.他们都没有工作.只有按钮显示在正确的位置,就像TextViews在此处但不可见.这些视图在Activity的onCreate()中调用.

<?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="wrap_content"
android:orientation="vertical"
tools:context=".EnterData">


    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/tvDateIn"
        android:layout_marginStart="15dp"
        android:layout_marginTop="15dp"
        tools:text="Date"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        android:id="@+id/tvDescIn"
        android:layout_marginTop="15dp"
        android:layout_marginStart="15dp"
        tools:text="Description"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        android:id="@+id/tvAmountIn"
        tools:text="California"
        android:layout_marginTop="15dp"
        android:layout_marginStart="15dp"
        android:textColor="#000"
        android:textSize="17sp"/>
    <Button
        android:id="@+id/btnSendData"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="30dp"
        android:text="Send Data"/>


</LinearLayout>

解决方法:

您尝试使用android:text而不是tools:text.工具:仅在Android Studio中可见的text.

或者,如果您使用的是tools:text,则应该使用yourTextView.setText(“ yourText”).

上一篇:android-以编程方式设置Textview的属性


下一篇:android-TextView文本未更新