Reputation: 403
This problem I am going to introduce, only happen in Android 4.0 +
I have a LinearLayout with 4 TableLayout, it's parent is a ScrollView.
I add TableRows dynamically into each TableLayout.
My TableRows are like this.
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/borda"
android:layout_margin="10dip"
android:paddingLeft="10dip"
>
<LinearLayout
android:id="@+id/l1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="15dip"
android:layout_marginBottom="15dip"
>
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/nome"
android:textStyle="bold"
android:textColor="#526691"
android:textSize="15sp"
android:paddingLeft="10dip"
android:paddingRight="5dip"
/>
<EditText
android:id="@+id/valorLabel"
android:layout_width="140dip"
android:layout_height="wrap_content"
android:textSize="15sp"
android:background="#ffffffff"
android:singleLine="true"
android:inputType="textCapSentences"
android:textColor="#777777" />
</LinearLayout>
</TableRow>
It seems to have a problem when the focused EditText is scrolled to out of the screen.
Question How can I know if the EditText is visible in the screen? Is there a way of remove focus in the EditText if it's parent is scrolled?
Second Question
Why my TableRow's background get white when EditText is focused ?
Upvotes: 0
Views: 1112
Reputation: 308
here is the answer of the first question: Android: how to check if a View inside of ScrollView is visible?
second one, you can set OnTouchListener on the parent view. When scrolled, its x or y value changes, then do clearFocus() on the EditText. Here is a good reference, check the Touch Event Listener part: http://www.techotopia.com/index.php/Android_Touch_and_Multi-touch_Event_Handling
If you put your source code and the error log, you would get much better specific answer.
Upvotes: 1