我正在尝试构建一个简单的表单,并且想在显示消息的顶部添加一个注释/标题/标题。我试图做到这一点,但文本已经离开了屏幕,下面的东西也被推掉了。我该如何解决这个问题?如何解决不适合屏幕的TextView问题,并将其他内容从屏幕上移开?
这是我layout.xml
,在这里它是在引擎收录:http://pastebin.com/fNBfQiz8
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:shrinkColumns="1"
android:stretchColumns="1" >
<TableRow
android:layout_marginBottom="2sp"
android:layout_marginTop="2sp"
android:layout_width="match_parent" >
<TextView
android:layout_width="match_parent"
android:text="You can only add a spot based on your current location" />
</TableRow>
<TableRow
android:layout_marginBottom="2sp"
android:layout_marginTop="2sp" >
<TextView android:text="Name:" />
<EditText android:id="@+id/name" />
</TableRow>
<TableRow
android:layout_marginBottom="2sp"
android:layout_marginTop="2sp" >
<TextView android:text="Address:" />
<EditText android:id="@+id/addr" />
</TableRow>
<TableRow
android:layout_marginBottom="2sp"
android:layout_marginTop="2sp" >
<TextView android:text="Type:" />
<Spinner
android:id="@+id/spinnerType"
style="@style/AppBaseTheme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:entries="@array/types_array"
android:prompt="@string/types_prompt" />
</TableRow>
<TableRow
android:layout_marginBottom="2sp"
android:layout_marginTop="2sp" >
<TextView android:text="Terrain:" />
<Spinner
android:id="@+id/spinnerTerrain"
style="@style/AppBaseTheme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:entries="@array/ratings_array"
android:prompt="@string/ratings_prompt" />
</TableRow>
<TableRow>
<TextView android:text="Difficulty:" />
<Spinner
android:id="@+id/spinnerDifficulty"
style="@style/AppBaseTheme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:entries="@array/ratings_array"
android:prompt="@string/ratings_prompt" />
</TableRow>
<TableRow
android:layout_marginBottom="2sp"
android:layout_marginTop="2sp" >
<TextView android:text="Description:" />
<EditText
android:id="@+id/desc"
android:gravity="top"
android:inputType="textMultiLine"
android:lines="2"
android:maxLines="2"
android:scrollHorizontally="false" />
</TableRow>
<Button
android:id="@+id/save"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Save"
android:layout_marginBottom="2sp"
android:layout_marginTop="2sp" />
</TableLayout>
你有把'android:layout_height =“wrap_content”'和'android:layout_width =“wrap_content”'。一个可能有用的想法... – TronicZomB 2013-03-06 22:00:10
嗨,谢谢。是的,我把它放在TextView和封装的TableRow中。它解决了屏幕问题的文本,但其他小部件仍然消失。 – 2013-03-06 22:03:31
这很好,也许尝试将这两行添加到每个“TextView”,“EditText”,“Spinner”和“Button”标记中。我不认为你需要'TableRow',但不能确定。我对Android还是比较陌生,但我认为每个可见的组件都必须具备这两个属性,但我不能100%确定。 – TronicZomB 2013-03-06 22:34:22