2014-02-10 2 views
1

여기 구현하려는 레이아웃의 매우 원시적 인 모형입니다. 물론 버튼과 물건이 있지만 문제는 없습니다.화면 맨 아래의 편집 문구 Android

enter image description here

당신은 내가 화면 하단에 EditText을 추가 할 볼 수 있듯이. 그러나 소프트 키보드를 열면 EditText이 보이지 않습니다. 매니페스트에 android:windowSoftInputMode="adjustResize"을 추가하면 레이아웃의 크기가 조정되지만 모든 것이 함께 짓밟 힙니다.

누구나 레이아웃을 올바르게 구성하여 멋지게 보이게 할 수 있습니까?

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true" > 

<LinearLayout 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:background="#B36E106F" 
android:orientation="vertical" 
android:baselineAligned="false" 
tools:context=".AddRoute" > 

<LinearLayout 
    android:id="@+id/content" 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="0.2" 
    android:background="#006E106F" 
    android:baselineAligned="false" > 

    <LinearLayout 
     android:id="@+id/left_column" 
     android:orientation="vertical" 
     android:layout_width="0dip" 
     android:layout_height="match_parent" 
     android:layout_weight="1" 
     android:layout_margin="10dp" 
     android:background="@drawable/add_route_column_background" > 

     <RelativeLayout 
      android:id="@+id/add_from_layout" 
      android:orientation="horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_margin="5dp" 
      android:layout_weight="1" > 

      <ImageView 
       android:id="@+id/add_from_image" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_alignParentTop="true" 
       android:src="@drawable/button_states" /> 

      <TextView 
       android:id="@+id/add_from" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:layout_alignParentTop="true" 
       android:layout_marginRight="5dp" 
       android:textColor="#fff" 
       android:textSize="18dp" 
       android:text="FROM:" /> 

      <TextView 
       android:id="@+id/add_from_result" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignRight="@+id/add_from" 
       android:textColor="#fff" 
       android:layout_centerVertical="true" /> 

     </RelativeLayout> 

     <RelativeLayout 
      android:id="@+id/add_date_layout" 
      android:orientation="horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_margin="5dp" 
      android:layout_weight="1" > 

      <ImageView 
       android:id="@+id/add_date_image" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_alignParentTop="true" 
       android:src="@drawable/button_states" /> 

      <TextView 
       android:id="@+id/add_date" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:layout_alignParentTop="true" 
       android:layout_marginRight="5dp" 
       android:textColor="#fff" 
       android:textSize="18dp" 
       android:text="DATE:" /> 

      <TextView 
       android:id="@+id/add_date_result" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignRight="@+id/add_date" 
       android:textColor="#fff" 
       android:layout_centerVertical="true" /> 

     </RelativeLayout> 

     <RelativeLayout 
      android:id="@+id/add_seats_layout" 
      android:orientation="horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_margin="5dp" 
      android:layout_weight="1" > 

      <ImageView 
       android:id="@+id/add_seats_image" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_alignParentTop="true" 
       android:src="@drawable/button_states" /> 

      <TextView 
       android:id="@+id/add_seats" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:layout_alignParentTop="true" 
       android:layout_marginRight="5dp" 
       android:textColor="#fff" 
       android:textSize="18dp" 
       android:text="SEATS:" /> 

      <TextView 
       android:id="@+id/add_seats_result" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignRight="@+id/add_seats" 
       android:textColor="#fff" 
       android:layout_centerVertical="true" /> 

     </RelativeLayout> 

     <RelativeLayout 
      android:id="@+id/add_notes_layout" 
      android:orientation="horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_margin="5dp" 
      android:layout_weight="1" > 

      <ImageView 
       android:id="@+id/add_notes_image" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_alignParentTop="true" 
       android:src="@drawable/button_states" /> 

      <TextView 
       android:id="@+id/add_notes" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:layout_alignParentTop="true" 
       android:layout_marginRight="5dp" 
       android:textColor="#fff" 
       android:textSize="18dp" 
       android:text="NOTES:" /> 

      <EditText 
       android:id="@+id/testEdit" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignRight="@id/add_notes" /> 

      <!-- <TextView 
       android:id="@+id/add_notes_result" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignRight="@+id/add_notes" 
       android:textColor="#fff" 
       android:layout_centerVertical="true" /> --> 

     </RelativeLayout> 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/right_column" 
     android:orientation="vertical" 
     android:layout_width="0dip" 
     android:layout_height="match_parent" 
     android:layout_weight="1" 
     android:layout_margin="10dp" 
     android:background="@drawable/add_route_column_background" > 

     <RelativeLayout 
      android:id="@+id/add_to_layout" 
      android:orientation="horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_margin="5dp" 
      android:layout_weight="1" > 

      <ImageView 
       android:id="@+id/add_to_image" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:layout_alignParentTop="true" 
       android:src="@drawable/button_states" /> 

      <TextView 
       android:id="@+id/add_to" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_alignParentTop="true" 
       android:layout_marginLeft="5dp" 
       android:textColor="#fff" 
       android:textSize="18dp" 
       android:text="TO:" /> 

      <TextView 
       android:id="@+id/add_to_result" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignLeft="@+id/add_to" 
       android:textColor="#fff" 
       android:layout_centerVertical="true" /> 

     </RelativeLayout> 

     <RelativeLayout 
      android:id="@+id/add_time_layout" 
      android:orientation="horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_margin="5dp" 
      android:layout_weight="1" > 

      <ImageView 
       android:id="@+id/add_time_image" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:layout_alignParentTop="true" 
       android:src="@drawable/button_states" /> 

      <TextView 
       android:id="@+id/add_time" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_alignParentTop="true" 
       android:layout_marginLeft="5dp" 
       android:textColor="#fff" 
       android:textSize="18dp" 
       android:text="TIME:" /> 

      <TextView 
       android:id="@+id/add_time_result" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignLeft="@+id/add_time" 
       android:textColor="#fff" 
       android:layout_centerVertical="true" /> 

     </RelativeLayout> 

     <RelativeLayout 
      android:id="@+id/add_price_layout" 
      android:orientation="horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_margin="5dp" 
      android:layout_weight="1" > 

      <ImageView 
       android:id="@+id/add_price_image" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:layout_alignParentTop="true" 
       android:src="@drawable/button_states" /> 

      <TextView 
       android:id="@+id/add_price" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_alignParentTop="true" 
       android:layout_marginLeft="5dp" 
       android:textColor="#fff" 
       android:textSize="18dp" 
       android:text="PRICE:" /> 

      <TextView 
       android:id="@+id/add_price_result" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignLeft="@+id/add_price" 
       android:textColor="#fff" 
       android:layout_centerVertical="true" /> 

     </RelativeLayout> 

     <RelativeLayout 
      android:id="@+id/add_stops_layout" 
      android:orientation="horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_margin="5dp" 
      android:layout_weight="1" > 

      <ImageView 
       android:id="@+id/add_stops_image" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:layout_alignParentTop="true" 
       android:src="@drawable/button_states" /> 

      <TextView 
       android:id="@+id/add_stops" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_alignParentTop="true" 
       android:layout_marginLeft="5dp" 
       android:textColor="#fff" 
       android:textSize="18dp" 
       android:text="STOPS:" /> 

      <TextView 
       android:id="@+id/add_stops_result" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignLeft="@+id/add_stops" 
       android:textColor="#fff" 
       android:layout_centerVertical="true" /> 

     </RelativeLayout> 
    </LinearLayout> 
</LinearLayout> 

<RelativeLayout 
    android:id="@+id/buttons" 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="0.8" 
    android:background="#006E106F" > 

    <Button 
     android:id="@+id/button_post" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@+id/cancel_button" 
     android:layout_alignParentRight="true" 
     android:layout_marginRight="40dp" 
     android:background="@drawable/post_button" 
     android:paddingBottom="15dp" 
     android:paddingLeft="40dp" 
     android:paddingRight="40dp" 
     android:paddingTop="15dp" 
     android:text="Post" 
     android:textColor="#fff" /> 

    <Button 
     android:id="@+id/cancel_button" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_centerVertical="true" 
     android:layout_marginLeft="31dp" 
     android:background="@drawable/cancel_button" 
     android:paddingBottom="15dp" 
     android:paddingLeft="40dp" 
     android:paddingRight="40dp" 
     android:paddingTop="15dp" 
     android:text="Cancel" 
     android:textColor="#fff" /> 

</RelativeLayout> 
</LinearLayout> 

</ScrollView> 

내가있는 ScrollView가 추가되었지만 여전히 키보드가 팝업 때, 화면이 그런 식으로 크기가 조정됩니다 : enter image description hereenter image description here

+1

후 XML 파일에 – Piyush

+0

@ John- P ost your xml – Namy

답변

1
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     xmlns:androidbootstrap="http://schemas.android.com/apk/res-auto" 
     xmlns:app="http://schemas.android.com/apk/res/com.hitchhiker.mobile" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:fillViewport="true" > 

    <RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:background="#B36E106F" 
    tools:context=".AddRoute" > 

    <EditText 
     android:id="@+id/driving_from_field" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="20dp" 
     android:background="@drawable/edittext_background_rounded" 
     android:hint="@string/from" 
     android:ems="5" > 
    </EditText> 

    <EditText 
     android:id="@+id/driving_to_field" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBaseline="@+id/driving_from_field" 
     android:layout_alignBottom="@+id/driving_from_field" 
     android:layout_marginLeft="50dp" 
     android:layout_toRightOf="@+id/driving_from_field" 
     android:background="@drawable/edittext_background_rounded" 
     android:hint="@string/to" 
     android:ems="5" /> 

    <EditText 
     android:id="@+id/price_field" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/driving_to_field" 
     android:layout_alignRight="@+id/driving_to_field" 
     android:layout_below="@+id/driving_to_field" 
     android:layout_marginTop="87dp" 
     android:background="@drawable/edittext_background_rounded" 
     android:hint="@string/price" 
     android:ems="10" > 

     <requestFocus /> 
    </EditText> 

    <Button 
     android:id="@+id/time_select" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/price_field" 
     android:layout_alignRight="@+id/price_field" 
     android:layout_below="@+id/driving_to_field" 
     android:layout_marginTop="22dp" 
     android:ems="10" /> 

    <Button 
     android:id="@+id/date_select" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBaseline="@+id/time_select" 
     android:layout_alignBottom="@+id/time_select" 
     android:layout_alignLeft="@+id/driving_from_field" 
     android:layout_alignRight="@+id/driving_from_field" /> 

    <EditText 
     android:id="@+id/seats" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/date_select" 
     android:layout_alignRight="@+id/date_select" 
     android:layout_alignTop="@+id/price_field" 
     android:background="@drawable/edittext_background_rounded" 
     android:hint="@string/seats" 
     android:ems="10" /> 

    <com.beardedhen.bbutton.BootstrapButton 
     android:id="@+id/save_button" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/seats" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="137dp" 
     android:text="@string/save" 
     androidbootstrap:roundedCorners="true" 
     androidbootstrap:size="default" 
     androidbootstrap:type="primary" > 
    </com.beardedhen.bbutton.BootstrapButton> 

    <ImageView 
     android:id="@+id/imageView2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/price_field" 
     android:layout_below="@+id/price_field" 
     android:layout_marginTop="28dp" 
     android:src="@drawable/abcpressed" /> 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignRight="@+id/seats" 
     android:layout_alignTop="@+id/imageView2" 
     android:src="@drawable/abc" /> 

</RelativeLayout > 

쓰기를 매니페스트 파일

<activity 
      android:name=".MainActivity" 
      android:label="@string/app_name" 
      android:windowSoftInputMode="adjustPan"> 
+0

감사합니다. 'android : windowSoftInputMode = "adjustPan"'이 매니페스트에서 트릭을 만들었습니다. 이것은 내가 찾고 있었던 것이다 –

+0

ok .. 즐거움. .. :) – Namy

0

것은 당신의 XML로 스크롤을 추가

다음은 현재 XML이다. 키보드가 팝업되면 메인 화면의 키보드 상단에있는 버튼으로 스크롤 할 수 있습니다. 있는 ScrollView와 레이아웃을 서라운드 당신

을 위해 작동 할 수 있습니다 그것을 밖으로 시도 :

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:fillViewport="true" > 

</ScrollView> 
+0

나는 당신의 제안을 사용했으나 화면은 여전히 ​​크기가 조정됩니다. 장치에서 스크린 샷을 게시했습니다. –

+0

android : linear_layout의 match_parent에 layout_height = "wrap_content"를 변경하려고 시도했습니다. – lantonis

+0

'match_parent'를 사용하면'wrap_content'를 사용하는 경고가 표시됩니다. 변경된 사항이 없습니다 –

0
It will be easier for you if you use Linear Layout rather than Relative Layout 
for this UI 

So you can follow this structure for creating your UI 

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

    // Main Layout Under Scroll View 

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

    // Layout used for creating your remaining views of ui. 

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

      <ImageView 
       android:id="@+id/imageView1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/ic_launcher" /> 

      <ImageView 
       android:id="@+id/imageView1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/ic_launcher" /> 

       add your remaining views here....... 
     </LinearLayout> 

     //Layout used for 2 edit text 


     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_marginBottom="20dp" 
      android:weightSum="2" > 

      <EditText 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" /> 

      <EditText 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" /> 
     </LinearLayout> 
    </LinearLayout> 

</ScrollView> 
관련 문제