2014-09-23 4 views
3

두 개의 버튼이있는 등록 양식을 만들었습니다. 이제 원하는 것은 키보드가 표시 될 때 하단에있는 두 개의 버튼이 키보드 위에 표시되고 숨겨지지 않아야한다는 것입니다. 이것을 달성하기 위해 내가 작성한 코드는 나에게 어떤 성공도주지 못했다.키보드 위 버튼 표시

XML 코드

<LinearLayout 
    android:layout_height="match_parent" 
    android:layout_width="match_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical"> 

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

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 


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


       <EditText 
        android:inputType="textPersonName" 
        style="@style/EditText" 
        android:hint="@string/firstname" 
        android:id="@+id/et_first_name" /> 


       <EditText 
        android:inputType="textPersonName" 
        style="@style/EditText" 
        android:hint="@string/lastname" 
        android:id="@+id/et_last_name" /> 

       <Button 
        style="@style/EditText" 
        android:text="@string/country" 
        android:id="@+id/bt_country" /> 


       <Button 
        style="@style/EditText" 
        android:text="@string/gender" 
        android:id="@+id/bt_gender" /> 

       <EditText 
        style="@style/EditText" 
        android:inputType="phone" 
        android:hint="@string/mobileno" 
        android:id="@+id/et_mobile_no" /> 

       <EditText 
        style="@style/EditText" 
        android:inputType="textEmailAddress" 
        android:hint="@string/email" 
        android:id="@+id/et_email" /> 


      </LinearLayout> 


     </LinearLayout> 
    </ScrollView> 

    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 

     <Button 
      style="@style/EditText" 
      android:id="@+id/bt_reg_cancel" 
      android:text="@string/cancel" 
      android:layout_gravity="bottom" 
      android:layout_weight="1" /> 

     <Button 
      style="@style/EditText" 
      android:text="@string/save" 
      android:id="@+id/bt_reg_save" 
      android:layout_gravity="bottom" 
      android:layout_weight="1" /> 
    </LinearLayout> 


</LinearLayout> 

안드로이드 매니페스트에 도움을

+0

왜 스크롤보기를 사용하지 않습니까? – Umair

+0

Button을 ScrollView 안에 넣고 시도하십시오 ...... –

+0

버튼 위치를 계속 유지하고 싶습니다 – user3917131

답변

1

을주세요, 재산 android:windowSoftInputMode="adjustResize"을 제공합니다. 키보드가 표시되면 레이아웃의 크기가 조정됩니다. 뭔가 바닥에있는 경우가

을 표시하면

그래서,이 키보드 위에 표시됩니다 "u는, 그것이 ??? 매우 도움이 될 것 나에게 상대 레이아웃 코드를 표시 할 수 있습니다하십시오 - user3917131 7 분 "

솔루션 일 전 -

  1. ) 중 하나가있는 ScrollView 자체 수익 레이아웃을 넣어. 키보드가 보이더라도 스크롤 할 수 있습니다.

2) 무게 접근 : - 있는 ScrollView -> 0.7 RelativeLayout의 -> 0.3 -> 그것은 당신의 바닥 레이아웃을 작성하고 진정한 속성 정렬 부모 바닥을 제공합니다. 이 방법을 사용하면 스크롤 뷰는 가중치 가이드 라인에 따라 0.7 개의 화면 만 차지하고 나머지는 하단 레이아웃에 따라 적용됩니다.

3.) scrollview를 제거하고 대신 선형 레이아웃으로 만듭니다. 상단 부모 상대 레이아웃을 만들고 하단 레이아웃에 부모가 일치하는 부모를 하단에 배치하고 위 레이아웃을 속성에 추가하십시오.

+1

Nah 내가 시도했지만 작동하지 않는 – user3917131

+0

전체 레이아웃은 scrollview에 있기 때문에 그것이 작동하지 않는 이유입니다. 스크롤 할 수 있기 때문에 크기가 조정되지 않습니다. scrollview를 제거하면 작동합니다. –

+0

스크롤보기에서 전체 레이아웃이 없습니다. – user3917131

0

예를 들어, ScrollView의 leyout_weight를 1로 설정해야합니다. 그리고 LinearLayout의 leyout_height를 "wrap_content"로 설정하십시오. 그리고 그것은 ScrollView의 layout_height를 0dp로 설정하는 것이 좋을 것입니다. 그래서 LinearLayout은 그것을 관리 할 수 ​​있습니다.

<LinearLayout 
    android:layout_height="match_parent" 
    android:layout_width="match_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical"> 

    <ScrollView 
     android:layout_weight="1" 
     android:layout_width="match_parent" 
     android:layout_height="0dp"> 
    </ScrollView> 
    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 

     <Button 
      style="@style/EditText" 
      android:id="@+id/bt_reg_cancel" 
      android:text="@string/cancel" 
      android:layout_gravity="bottom" 
      android:layout_weight="1" /> 
     <Button 
      style="@style/EditText" 
      android:text="@string/save" 
      android:id="@+id/bt_reg_save" 
      android:layout_gravity="bottom" 
      android:layout_weight="1" /> 
    </LinearLayout> 


</LinearLayout> 

그 트릭을해야합니다.