0

I have problem with my table layout and TextView components. I don't know why I can't limit EditText and AutoCompleteTextView sizes and both components mess up my layout. As You can see on attached image below those components goes over screen edge (on the right side). Because of that spinner field is too large too.

I thought that android:layout_width="match_parent" (or fill_parent) should help, but not this time.

Layout code is below image.

I'll be grateful for any tips/help. I'm using HTC Wildfire S with Android 2.3.5.

asd

<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>
Pawel
  • 798
  • 8
  • 28
  • 1
    I would suggest using Placeholders from the EditText control. Much nicer UI when you power up to Android 4+ – Joe Simpson Oct 20 '12 at 22:24
  • @JoeSimpson Thanks, it's not resolving my problem and doesn't look that nice on 2.3.5, but it's helpful tip. Thanks. – Pawel Oct 20 '12 at 22:51

1 Answers1

1

The problem is your android:ems="10" is forcing those elements to draw larger than the available screen. Try changing this to some other value, or removing it all together.

withoutclass
  • 564
  • 8
  • 16