title: Not changing focus when calling setVisibility(View.VISIBLE)
body: <p>I have a scenario where when an action occurs I want to make certain fields visible. This works fine, however when I call setVisible(View.VISIBLE) on a LinearLayout that contains a few other fields, such as a TextEdit, the focus shifts to the TextEdit (or at least the screen scrolls to it).</p>
  
  <p>Is there a way to not have the focus change when calling setVisibility(View.VISIBLE)?</p>
  
  <p>The XML layout of the LinearLayout I can calling setVisible on:</p>
  
  <pre><code>&lt;LinearLayout 
      android:orientation="vertical"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:focusable="true"
      android:focusableInTouchMode="true"&gt;
  
      &lt;TextView
          android:id="@+id/name"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:textSize="18sp"
          android:textStyle="normal"
          android:paddingLeft="5dp"
          android:paddingRight="5dp"
          android:paddingBottom="5dp"
          android:text="" /&gt;
  
       &lt;EditText android:id="@+id/entry"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:inputType="textMultiLine"
          android:gravity="right" /&gt; 
  
      &lt;View
          android:layout_marginTop="8dp"
          android:layout_width="match_parent"
          android:layout_height="1dp"
          android:background="@color/grey"
          android:visibility="gone" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>The code that initializes it:</p>
  
  <pre><code>private TextView mName;
  private EditText mEntry;
  </code></pre>
  
  <p>...</p>
  
  <pre><code>     private void initialize() {
  
          LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          inflater.inflate(R.layout.field_multiline_entry, this);
  
          // setup fields
          mName = (TextView)findViewById(R.id.name);
          mEntry = (EditText)findViewById(R.id.entry);
          mEntry.addTextChangedListener(textWatcher);
  
      }
  </code></pre>
  
  <p>And the code that is calling the setVisibility:</p>
  
  <pre><code>        if(sectionFieldView != null &amp;&amp; sectionFieldView.getVisibility() != View.VISIBLE) 
          {
              sectionFieldView.setVisibility(View.VISIBLE);
          }
  </code></pre>
  
  <p>Thanks!</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Thanks to my friend below, the following code works. It basically makes all the descendants of the LinearLayout unable to gain focus, which means when made visible the screen does not scroll to them as they do not gain focus. Only way to date I have found to keep this from happening...</p>
  
  <pre><code>        ((ViewGroup) fieldView).setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
          fieldView.setVisibility(View.VISIBLE);
          ((ViewGroup) fieldView).setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
  </code></pre>