0

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 ?

Renaro Santos
  • 403
  • 1
  • 7
  • 19
  • To answer your first question `yourEditText.getVisibility() == View.VISIBLE)` will `return true` if it is `Visible`. What is the problem it is giving you? – codeMagic May 03 '13 at 19:52
  • http://stackoverflow.com/questions/16293230/android-form-with-edittext-makes-the-screen-flash ... This is my real problem. I will try this solution. – Renaro Santos May 03 '13 at 20:16

1 Answers1

1

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.

Community
  • 1
  • 1
tjPark
  • 308
  • 1
  • 11
  • Actually there are many EditText's, no one of them can be focused outside the screen, otherwise the screen will flash(blink). Your solution worked in parts. I am clearing the focus of all EditText, but sometimes, it's still flashing. And when the EditText is focused, the TableRow's background gets white. @tjPark – Renaro Santos May 03 '13 at 21:53