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>
答案 0 :(得分:3)
您尝试使用android:text
而不是tools:text
。 tools:text
仅在Android Studio中可见。
或者如果您使用的是yourTextView.setText("yourText")
,则应该使用tools:text
。
答案 1 :(得分:0)
在xmlView中使用android:text =“ abc”代替在xml中使用tool:text。 作为工具:文本用于android studio布局预览。运行应用程序时,它不显示文本。 而android:text用于将文本设置为textview,按钮等。
答案 2 :(得分:0)
是的,一切正常,仅放置android:text就可以了。 非常感谢。