2

등록 페이지가 있습니다. 네 개의 EditText가 있습니다. 세 번째 EditText를 클릭하면 하나의 LinearLayout (비밀번호 가이드 라인 가정)이 표시되어야하며 동시에 전체 레이아웃을 스크롤해야 모든 가이드 라인을 볼 수 있습니다. 다른 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> 

이 사용하는 안드로이드를 시도하십시오 : windowSoftInputMode = "AdjustResize"를 매니페스트에 코드 아래와 같은 활동을 decraing 곳

<activity 
    android:name=".YourActivity" 
    android:parentActivityName="XXX.XXX.XXXX" 
    android:windowSoftInputMode="AdjustResize" />