【发布时间】:2014-06-12 09:09:36
【问题描述】:
我有这个 xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.gelasoft.answeringball.MainActivity$PlaceholderFragment" >
<ImageView
android:id="@+id/sphereIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:contentDescription="@string/magicBallDescr"
android:src="@drawable/ic_launcher" />
<LinearLayout
android:id="@+id/table"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/sphereIcon"
android:orientation="horizontal" >
<TextView
android:id="@+id/txtAnswer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<EditText
android:id="@+id/launch_codes"
android:layout_width="match_parent"
android:layout_height="106dp"
android:hint="@string/textHint"
android:inputType="text" />
<Button
android:id="@+id/btnAsk"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/btnAskQ"
/>
</LinearLayout>
</RelativeLayout>
一切都很完美,但按钮不会显示。
我在这里缺少什么?我知道即使对于初学者来说这也是基本的东西,但我发现作为 xml 世界的新手很难理解。
【问题讨论】:
-
您的内部
LinearLayout具有“水平”方向。我猜你的视图不能在一行中显示 TextView、EditText 和 Button。没有那么多空间。 -
尤其如此,在EditText占用了TextView之后的所有剩余空间之后...
-
@Kody 哦,我明白了,现在它出现了。你能回答吗,这样我就可以接受了。
标签: java android xml android-fragments android-activity