2017-03-18 1 views
1

일부 내용으로 FrameLayout 또는 LinearLayout을 표시해야하는 활동이 있습니다. 화면 하단에 버튼이 있어야합니다. 안드로이드는 단지 하나의 rootview를 허용하기 때문에 버튼과 레이아웃을 모두 포장해야합니다. AndroidManifest.xml을 통해 "adjustResize"플래그를 설정했습니다. 이 플래그는 소프트 키보드의 맨 아래에서 맨 위로 단추를 이동해야합니다. 문제는 내가 이것을 달성 할 수 없다는 것입니다. 대신 버튼이 소프트 키보드 아래에 숨겨져 있습니다 - 버튼이 움직이지 않습니다. 표시된 키보드로 버튼을 올바른 위치로 이동하는 유일한 방법은 선형 또는 프레임 레이아웃을 ScrollView로 대체하는 것입니다.button이 stateVisible 플래그가있는 레이아웃에서 보이는 키보드로 크기가 조정되지 않았습니다.

제 질문은 ScrollView에서만 작동하는 이유는 무엇입니까? 나는 이미 여러보기에서이 aproach를 사용했으며 다른 종류의보기 그룹에서도 항상 작동했습니다. 누군가가 어떤 생각을 가지고 있습니까? 당신은 아이디 create_account_text와 텍스트 뷰에 336dp의 marginTop를 추가

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:tools="http://schemas.android.com/tools"> 

    <RelativeLayout 
     style="@style/FirebaseUI.WrapperStyle" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <!-- 
      Since the TextInputLayouts change size based on whether or not an error 
      is showing we use a relative layout to position them absolutely 
     --> 
     <android.support.design.widget.TextInputLayout 
      android:id="@+id/email_layout" 
      style="@style/FirebaseUI.Text.TextInputLayout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:paddingTop="16dp" 
      android:transitionGroup="true" 
      android:transitionName="email_field" 
      app:errorTextAppearance="@style/FirebaseUI.Text.ErrorText" 
      app:hintTextAppearance="@style/FirebaseUI.Text.HintText" 
      tools:ignore="UnusedAttribute"> 

      <android.support.design.widget.TextInputEditText 
       android:id="@+id/email" 
       style="@style/FirebaseUI.EditText.EmailField"/> 

     </android.support.design.widget.TextInputLayout> 

     <android.support.design.widget.TextInputLayout 
      android:id="@+id/name_layout" 
      style="@style/FirebaseUI.Text.TextInputLayout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:paddingTop="112dp" 
      app:errorTextAppearance="@style/FirebaseUI.Text.ErrorText" 
      app:hintTextAppearance="@style/FirebaseUI.Text.HintText"> 

      <android.support.design.widget.TextInputEditText 
       android:id="@+id/name" 
       style="@style/FirebaseUI.EditText" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:inputType="textPersonName" 
       android:hint="@string/name_hint"/> 

     </android.support.design.widget.TextInputLayout> 

     <android.support.design.widget.TextInputLayout 
      android:id="@+id/password_layout" 
      style="@style/FirebaseUI.Text.TextInputLayout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:paddingTop="224dp" 
      app:errorTextAppearance="@style/FirebaseUI.Text.ErrorText" 
      app:hintTextAppearance="@style/FirebaseUI.Text.HintText" 
      app:passwordToggleEnabled="true"> 

      <android.support.design.widget.TextInputEditText 
       style="@style/FirebaseUI.EditText.PasswordField" 
       android:id="@+id/password" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"/> 

     </android.support.design.widget.TextInputLayout> 

     <TextView 
      android:id="@+id/create_account_text" 
      android:layout_height="wrap_content" 
      android:layout_width="match_parent" 
      android:layout_marginTop="336dp" 
      style="@style/FirebaseUI.Text.BodyText"/> 


     <Button 
      style="@style/FirebaseUI.Button" 
      android:layout_below="@id/create_account_text" 
      android:id="@+id/button_create" 
      android:layout_alignParentEnd="true" 
      android:layout_alignParentRight="true" 
      android:text="@string/button_text_save"/> 

    </RelativeLayout> 

</FrameLayout> 

감사

답변

1

:

이처럼 내 레이아웃 모습입니다. 이것은 대부분의 장치에서 많이 발생하므로 소프트 키보드가 나타나면 표시된 화면의 크기가 다른보기와 336dp 여백 위쪽에 필요한 크기보다 작습니다.

ScrollView를 추가 할 때 softKeyboard가 나타나면보기가 아래로 스크롤되어 단추가 표시되지만 다른 것은 표시되지 않습니다.

당신이 필요로하는 것이 무엇인지 모르겠지만,이 336dp가 화면에 빈 공간 만 있으면, RelativeLayout을 LinearLayout으로 변환하고 레이아웃 가중치를 사용하여 빈 공간을 채울 수 있습니다. 키보드가 나타나면 공백이 조정됩니다.

도움이 더 필요하면 스크린 샷을 제공해주세요.

관련 문제