【发布时间】:2014-11-20 05:30:17
【问题描述】:
我有一个简单的表格布局,如下所示:
我的问题是,每当我在 Artist、Venue 或 Comments EditText 框中键入文本时,一旦文本字符串与 Date TextView 的开头垂直对齐,TextView 的起始位置就会移动位置以与字符串保持一致字符数;像这样:
我不确定 Button 是否正在尝试将其终点与字符串匹配,或者 TextView 是否正在尝试将其起点与字符串匹配,但无论哪种方式都不正确。
谁能告诉我这里发生了什么? 提前致谢!
这是显示页面的 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"
tools:context="${relativePackage}.${activityClass}" >
<TextView
style="@style/titleBar"
android:id="@+id/addTitle"
android:text="@string/add" />
<TableLayout
style="@style/my_table"
android:id="@+id/addTable"
android:layout_below="@+id/addTitle">
<TableRow>
<TextView
style="@style/largeText"
android:text="@string/artistName"/>
</TableRow>
<TableRow>
<EditText
style="@style/tableEditText"
android:id="@+id/editName"/>
</TableRow>
<TableRow>
<TextView
style="@style/largeText"
android:text="@string/venue"/>
</TableRow>
<TableRow>
<EditText
style="@style/tableEditText"
android:id="@+id/editVenue"/>
</TableRow>
<TableRow>
<TextView
style="@style/largeText"
android:text="@string/date"/>
</TableRow>
<TableRow>
<Button
android:background="@android:color/transparent"
android:drawableRight="@drawable/event_1"
android:id="@+id/setDateButton"/>
<TextView
style="@style/tableEditText"
android:layout_weight="3"
android:layout_width="200dp"
android:id="@+id/editDate"/>
</TableRow>
<TableRow>
<TextView
style="@style/largeText"
android:text="@string/comments"/>
</TableRow>
<TableRow>
<EditText
style="@style/tableEditText"
android:inputType="textNoSuggestions|textCapSentences|textMultiLine"
android:lines="3"
android:id="@+id/editComments"/>
</TableRow>
</TableLayout>
<Button
android:id="@+id/addButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="@drawable/add"
android:background="@android:color/transparent"
android:textColor="@color/grey"
android:padding="20dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
这里是styles.xml 文件:
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="largeText">
<item name="android:textColor">@color/grey</item>
<item name="android:textSize">25sp</item>
<item name="android:padding">3dp</item>
<item name="android:layout_weight">1</item>
<item name="android:gravity">left</item>
<item name="android:layout_marginRight">20sp</item>
</style>
<style name="largeText2">
<item name="android:textSize">25sp</item>
<item name="android:padding">3dp</item>
<item name="android:background">@color/bgOrange</item>
<item name="android:textColor">@color/nearBlack</item>
<item name="android:layout_weight">1</item>
<item name="android:gravity">left</item>
<item name="android:layout_marginRight">20sp</item>
</style>
<style name="titleBar">
<item name="android:textColor">#fff</item>
<item name="android:textSize">25sp</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_alignParentTop">true</item>
<item name="android:layout_centerHorizontal">true</item>
<item name="android:gravity">left</item>
<item name="android:padding">20sp</item>
<item name="android:background">@color/headingOrange</item>
</style>
<style name="my_table">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:padding">15sp</item>
</style>
<style name="tableEditText">
<item name="android:inputType">textCapSentences|textNoSuggestions|textAutoComplete</item>
<item name="android:background">@color/bgOrange</item>
<item name="android:textColor">@color/nearBlack</item>
<item name="android:gravity">left</item>
<item name="android:padding">3dip</item>
<item name="android:textSize">25sp</item>
<item name="android:layout_weight">1</item>
</style>
<style name="smallIcon">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_gravity">left</item>
<item name="android:padding">2dp</item>
</style>
</resources>
【问题讨论】: