2016-04-15 68 views
-1
<RelativeLayout> 
     <LinearLayout 
      android:id="@+id/f1"> 
     <EditText 
         android:id="@+id/f1textA" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:singleLine="true" /> 
     <EditText 
         android:id="@+id/f1textB" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:singleLine="true" /> 
     </LinearLayout> 
    </RelativeLayout> 
    <RelativeLayout> 
     <LinearLayout 
      android:id="@+id/f2"> 
     ... 
     </LinearLayout> 
    </RelativeLayout> 

如何在f1textA上onFocus时隐藏f2 LinearLayout,并将f1设置为全屏。当迷失在f1textA上时,显示f2和f1保持原来的高度。 (用于隐藏/显示自定义键盘)如何在onFocus on EditText时隐藏LinearLayout

回答

0

试试这个,

f1textA.setOnFocusChangeListener(new View.OnFocusChangeListener() { 
      @Override 
      public void onFocusChange(View v, boolean hasFocus) { 

       if(hasFocus){ 
       //Hide f2 linear layout and show f1 linear layout 

       } else{ 
       //show f1 linear layout and show f2 linear layout 
       } 

      } 
     }); 
+0

如何设置F1(高度)隐藏之后占据从F2的空间? –

+0

将父布局视为垂直线性布局,并将f1和f2线性布局放入其中。 –