2

HTML 파일에서 선택한 양식 필드를 프로그래밍 방식으로 LinearLayout에 추가하려고합니다. 아래쪽에 다음 버튼이 있지만 계속 화면에서 잘립니다. 나는 태블릿에서 그것을 시도하고 여전히 나타나지 않습니다.안드로이드 ScrollView가 아래쪽에서 잘림

다음은 응용 프로그램의 스크린 샷입니다 : screenshot

당신이 볼 수 있듯이, 요소가 렌더링지고 있지만 마지막은 어떤 이유로 화면을 실행합니다.

조각의 XML :

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/main_content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context=".dataInput.DataInputActivity"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:layout_scrollFlags="scroll|enterAlways" 
      app:popupTheme="@style/AppTheme.PopupOverlay"> 

     </android.support.v7.widget.Toolbar> 

     <android.support.design.widget.TabLayout 
      android:id="@+id/tabs" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 

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

    <android.support.v4.view.ViewPager 
     android:id="@+id/container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="end|bottom" 
     android:layout_margin="@dimen/fab_margin" 
     android:src="@android:drawable/ic_media_play" /> 

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

내가 조각의 onCreateView에서 만든 방법 formInflator를 호출하고 조각에서의 LinearLayout을 통과하고하고 Elements 객체 (:

<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    tools:context=".dataInput.PropertyInfoFragment" 
    android:layout_height="match_parent" 
    android:layout_width="match_parent" 
    android:paddingLeft="20dp" 
    android:paddingRight="20dp"> 

    <ScrollView 
     android:fillViewport="true" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 

      <LinearLayout 
       android:id="@+id/linear_layout_property_info" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical"> 

      </LinearLayout> 
      <Button 
       android:id="@+id/nextButton" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="@string/next" 
       android:background="@color/colorPrimary" 
       android:textColor="@android:color/white"/> 
     </LinearLayout> 

    </ScrollView> 

</FrameLayout> 

는 활동의 XML을 호출 Jsoup 라이브러리에서) LinearLayout에 넣으려는 모든 요소가 들어 있습니다.

내가 잘못 뭐하는 거지

public void formInflator(LinearLayout parentLayout, Elements formElements) { 
    TextInputLayout index = null; 
    for(Element textField : formElements) { 
     TextInputEditText editText = new TextInputEditText(context); 
     editText.setId(View.generateViewId()); 
     editText.setHint(textField.id()); 
     editText.setText(textField.text()); 
     LinearLayout.LayoutParams editTextParams = new LinearLayout.LayoutParams(
       LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); 
     editText.setLayoutParams(editTextParams); 

     TextInputLayout textInputLayout = new TextInputLayout(context); 
     textInputLayout.setId(View.generateViewId()); 
     textInputLayout.setTag(textField.id()); 
     RelativeLayout.LayoutParams textInputLayoutParams = new RelativeLayout.LayoutParams(
       RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); 
     if (index == null) 
      index = textInputLayout; 
     else 
      textInputLayoutParams.addRule(RelativeLayout.BELOW, index.getId()); 

     textInputLayout.setLayoutParams(textInputLayoutParams); 
     textInputLayout.addView(editText, editTextParams); 

     parentLayout.addView(textInputLayout, textInputLayoutParams); 
     index = textInputLayout; 
    } 
} 

어떤 생각 :

여기 방법 formInflator입니까?

+0

그것이있는 ScrollView가 확실히 있다면 당신은 그냥 "차단"을 내용의 나머지 부분을보기 위해 스크롤 할 수 있습니까? 달성하고자하는 의도 된 행동은 무엇입니까? – wanpanman

+0

@wanpanman 나는 내 질문에 제대로 말하지 않았다고 생각한다. 문제는 모든 EditText보기 후에 버튼이 있어야한다는 것입니다. 그러나 ScrollView 아래쪽으로 끝까지 스크롤하지 않습니다. 스크린 샷에 표시된 내용은 가장 먼 것입니다. – Mak

+0

액션 바에 기분이 들었습니다. 나는 같은 문제에 직면하고있다. 나는 탭 활동을 사용하고 있고, 탭 안에는'EditText'가 있습니다. 처음에는 바닥이 OP와 똑같이 잘립니다. 하지만 일단 'EditText'를 활성화하고 소프트 키보드가 나타나면 액션 바가 사라집니다 (이것은 해결할 수없는 또 다른 문제입니다). 그러나 키보드가 제거 된 후에도'ScrollView'는 완벽하게 작동합니다 (액션 바 아직 실종 상태입니다.) – xSooDx

답변

5

ScrollView layout_height를 match_parent으로 변경하십시오. wrap_content을 얻는 것은 바로 그 아이입니다.

+0

고마워, 그게 분명 도움이된다! 그러나 그것은 문제를 완전히 해결하지 못합니다. 이제 마지막'EditText' 뷰의 맨 아래로 스크롤하지만'Button'은 여전히 ​​끊어집니다.두 번째'LinearLayout' 위의'Button '을 움직여 보았습니다. 그리고 마지막에'EditText'가 다시 잘리는 결과가되었습니다 – Mak

+0

'formInflator'에서'parentLayout'에 추가 된'TextInputLayout'에 대한'RelativeLayout' 레이아웃 매개 변수를 설정하려고합니다 '. 그러나'parentLayout'은'RelativeLayout'이 아닌'LinearLayout'입니다. 그래서 여러분이 기대하는대로 할 수는 없습니다. –

3

제가 발견 한 가장 가까운 해결책은 유령보기를 추가하는 것입니다 ... ScrollView가 마지막 요소의 일부를 먹는 경우 쿠키를 제공하십시오.

예는 :

<View 
    android:layout_width="match_parent" 
    android:layout_height="25dp"/> 
0

는 활동에 작업 표시 줄을 추가합니다. 안드로이드는 스크롤 할 때보기 포트를 더 잘 인식하고 하단에 누락 된 툴바 높이를 추가합니다.

AppCompatActivity

Toolbar toolbar = getActivity().findViewById(R.id.toolbar); 
setSupportActionBar(toolbar); 
// if needed... 
getSupportActionBar().setDisplayShowTitleEnabled(false); 
관련 문제