2

その4のEditTextが存在する中で、私は第三のEditText 1のLinearLayout(パスワードのガイドラインを想定)見えるように持っていると同時に、総レイアウトはすべてguidelines.When他のEditTextを表示するには、スクロールする必要があります(1をクリックしたときに私は、登録ページを持っています、2または4)にフォーカスを当てて、このLinearLayout(パスワードガイドライン)を閉じる必要があります。私はたくさん試して、私はたくさんの検索をしましたが、私のために解決策はありませんでした。私を助けてください。私は小さなプロジェクトをしたことを理解するために、それを見てください。特定のEditTextにフォーカスがあるとき、ページ全体をスクロールしますか?

public class MainActivity extends AppCompatActivity { 
private EditText mEditText1,mEditText2,mEditText3,mEditText4; 
private LinearLayout ll,root; 
ScrollView mScrollView ; 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    root = (LinearLayout) findViewById(R.id.ll_linear_layout); 
    ll = (LinearLayout) findViewById(R.id.ll); 
    mEditText1 = (EditText) findViewById(R.id.et1); 
    mEditText2 = (EditText) findViewById(R.id.et2); 
    mEditText3 = (EditText) findViewById(R.id.et3); 
    mEditText4 = (EditText) findViewById(R.id.et4); 

    mEditText1.setOnFocusChangeListener(mListener1); 
    mEditText2.setOnFocusChangeListener(mListener2); 
    mEditText3.setOnFocusChangeListener(mLayoutExtract); 
    mEditText4.setOnFocusChangeListener(mListener4); 


    mScrollView = new ScrollView(this); 

} 

View.OnFocusChangeListener mListener1 = new View.OnFocusChangeListener() { 
    @Override 
    public void onFocusChange(View view, boolean b) { 
     if (b) { 

     } else { 

     } 

    } 
}; 
View.OnFocusChangeListener mListener2 = new View.OnFocusChangeListener() { 
    @Override 
    public void onFocusChange(View view, boolean b) { 
     if (b) { 

     } else { 

     } 

    } 
}; 
View.OnFocusChangeListener mLayoutExtract = new View.OnFocusChangeListener() { 
    @Override 
    public void onFocusChange(View view, boolean b) { 
     if (b) { 
      ll.setVisibility(View.VISIBLE); 
     } else { 
      ll.setVisibility(View.GONE); 
     } 

    } 
}; 
View.OnFocusChangeListener mListener4 = new View.OnFocusChangeListener() { 
    @Override 
    public void onFocusChange(View view, boolean b) { 
     if (b) { 


     } else { 

     } 

    } 
}}; 


<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
android:id="@+id/ll_linear_layout" 
xmlns:android="http://schemas.android.com/apk/res/android"> 
<EditText 
    android:layout_marginTop="200dp" 
    android:id="@+id/et1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:hint="first name"/> 
<EditText 
    android:id="@+id/et2" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:hint="second name"/> 
<EditText 
    android:id="@+id/et3" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:hint="second name"/> 
    <LinearLayout 
     android:id="@+id/ll" 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="300dp" 
     android:visibility="gone"> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textSize="75dp" 
      android:textColor="#000000" 
      android:text="Hidable text"/> 
    </LinearLayout> 
<EditText 
    android:id="@+id/et4" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:hint="second name"/> 

答えて

1

この

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 
<LinearLayout 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
android:id="@+id/ll_linear_layout" 
xmlns:android="http://schemas.android.com/apk/res/android"> 
<EditText 
    android:layout_marginTop="200dp" 
    android:id="@+id/et1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:hint="first name"/> 
<EditText 
    android:id="@+id/et2" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:hint="second name"/> 
<EditText 
    android:id="@+id/et3" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:hint="second name"/> 
    <LinearLayout 
     android:id="@+id/ll" 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="300dp" 
     android:visibility="gone"> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textSize="75dp" 
      android:textColor="#000000" 
      android:text="Hidable text"/> 
    </LinearLayout> 
<EditText 
    android:id="@+id/et4" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:hint="second name"/> 
</LinearLayout> 
</ScrollView> 

はこの使用のAndroidを試してみて試してみてください。windowSoftInputMode = "AdjustResizeを" あなたのマニフェストにあなたのコードの下のようなあなたの活動をdecraingされている場合

<activity 
    android:name=".YourActivity" 
    android:parentActivityName="XXX.XXX.XXXX" 
    android:windowSoftInputMode="AdjustResize" /> 
関連する問題