【发布时间】:2019-04-25 12:14:36
【问题描述】:
Textview 项目不可见。他们下面的Button是。
尝试将LinearLayout 更改为RelativeLayout,将match_parent 和内容更改为0dp。他们都没有工作。只有按钮显示在正确的位置,好像 TextView 在那里但不可见。这些视图在 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>
【问题讨论】:
-
请附上一张截图。
-
您是否尝试在 TextViews 中将“tools:text”替换为“android:text”?
-
用 android:text 改变 tools:text
标签: android android-layout textview