TextView消失了,Button可见

问题描述 投票:3回答:3

Textview项目不可见。他们下面的Button是。

尝试用LinearLayout改变RelativeLayout,用match_parent改变了0dp和内容。他们都没有工作。只有按钮显示在正确的位置,就好像TextViews在那里但不可见。这些视图在活动的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 android-layout textview
3个回答
3
投票

你尝试使用android:text而不是tools:texttools:textonly在Android Studio中可见。

或者如果你使用的是yourTextView.setText("yourText"),你应该使用tools:text


0
投票

而不是使用工具:xml中的文本在textView中使用android:text =“abc”。作为工具:文本用于android studio布局预览。运行应用程序时,它不显示文本。 android:text用于将文本设置为textview,按钮等。


0
投票

是的,这一切都工作,只是放置android:文本显示它。非常感谢你。

© www.soinside.com 2019 - 2024. All rights reserved.