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:text
而不是tools:text
。 tools:text
only在Android Studio中可见。
或者如果你使用的是yourTextView.setText("yourText")
,你应该使用tools:text
。
而不是使用工具:xml中的文本在textView中使用android:text =“abc”。作为工具:文本用于android studio布局预览。运行应用程序时,它不显示文本。 android:text用于将文本设置为textview,按钮等。
是的,这一切都工作,只是放置android:文本显示它。非常感谢你。