我有我的表格佈局和TextView組件的問題。我不知道爲什麼我不能限制EditText和AutoCompleteTextView的大小,並且這兩個組件都搞亂了我的佈局。 正如您可以在下面附加的圖像上看到的那些組件越過屏幕邊緣(在右側)。因爲那個旋轉器領域也太大了。EditText字段越過屏幕邊緣
我認爲android:layout_width="match_parent"
(或fill_parent
)應該有所幫助,但不是這次。
佈局代碼在圖像下方。
我會很感激任何提示/幫助。我在Android 2.3.5上使用HTC Wildfire S。
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:isScrollContainer="true"
android:overScrollMode="always"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarStyle="outsideInset"
android:scrollbars="vertical">
<TableLayout
android:id="@+id/assiociatecode_tableleyout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:baselineAligned="true"
android:measureWithLargestChild="false" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/associatecode_lbl_code"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/associate_code_activity"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<EditText
android:id="@+id/associatecode_edit_code"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="text" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/associatecode_lbl_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/associate_code_activity_product"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<AutoCompleteTextView
android:id="@+id/associatecode_edit_product"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/primary_text_light"
android:ems="10">
<requestFocus/>
</AutoCompleteTextView>
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/associatecode_lbl_productgroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/associate_code_activity_productgroup"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<Spinner
android:id="@+id/associatecode_edit_productgroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</TableRow>
</TableLayout>
</ScrollView>
我建議使用EditText控件的佔位符。當您啓動Android 4+時,更好的用戶界面 –
@JoeSimpson謝謝,它不能解決我的問題,並且在2.3.5上看起來不太好,但它有助於提示。謝謝。 – Pawel