对于你们中的一些人来说,这似乎是一个非常简单的问题,但即使在尝试了本网站上提出的众多解决方案之后,我也找不到显示我的 TextView 的方法。并不是说我使用的是适用于 Android 的内置 Eclipse XML 工具,也不是说 TextView 在此图形布局上可见。这是我到目前为止所得到的:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/home_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:contentDescription="@string/no_of_screens"
android:id="@+id/imageViewHome"
android:layout_width="290dp"
android:layout_height="212dp"
android:layout_gravity="center_horizontal"
android:paddingTop="40dp"
android:src="@drawable/logo" />
<RelativeLayout
android:id="@+id/relativeid"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<Button
android:id="@+id/launch_button"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="80dp"
android:text="@string/launch" />
<Spinner
android:id="@+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/launch_button"
android:layout_marginRight="20dp"
android:layout_toLeftOf="@+id/launch_button"
android:entries="@array/num_array"
android:prompt="@string/screen_prompt"
android:textSize="8pt" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/launch_button"
android:layout_alignBottom="@+id/launch_button"
android:layout_marginRight="16dp"
android:layout_toLeftOf="@+id/spinner1"
android:text="@string/no_of_screens"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
</LinearLayout>
至于现在,所有其他元素都可以正确显示。任何帮助将不胜感激!
谢谢
最佳答案
你想要你的 textView 在哪里?
我会松开这两个:
layout_alignBaseline="@+id/launch_button
layout_alignBottom="@+id/launch_button
并使用其中之一:
layout_below="@+id/launch_button
layout_above="@+id/launch_button
这会将它放在按钮上方或下方。
关于java - TextView 未显示/相对布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11016695/