0

그래서 나는 안드로이드 프로그래밍의 여러 가지를 둘러싼 문자 메시지 앱을 만들고 있는데, 아직 온라인에서 답을 찾을 수없는 문제가 발생했습니다. 나는이 사이트와 다른 안드로이드 프로그래밍 포럼에서 여러 답변을 시도했지만 그 중 하나가 매번 작동하지 않았습니다. 다른 예제는 한 번만 작동하는 반면 다른 예제는 두 번 작동합니다. 이것은 UI 기능에 대해 알아야 할 앱에 남아있는 유일한 것입니다.안드로이드에 소프트 키보드가 나타날 때 ScrollView를 맨 아래로 스크롤 하시겠습니까?

나는 등의 XML 레이아웃 파일이 있습니다

<RelativeLayout 
     android:id="@+id/rlActionBar2" 
     android:layout_width="fill_parent" 
     android:layout_height="44dp" > 
    </RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/rlAddContact" 
     android:layout_width="fill_parent" 
     android:layout_height="44dp" 
     android:layout_below="@+id/rlActionBar2" 
     android:background="@drawable/new_message_background" 
     android:padding="0dp" > 

     <TextView 
      android:id="@+id/tvTo" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_centerVertical="true" 
      android:layout_marginLeft="8dp" 
      android:text="@string/text_to" 
      android:textColor="#7F7F7F" 
      android:textSize="17sp" /> 

     <EditText 
      android:id="@+id/txtContact" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBaseline="@id/tvTo" 
      android:layout_marginLeft="6dp" 
      android:layout_toLeftOf="@+id/btnAddContact" 
      android:layout_toRightOf="@id/tvTo" 
      android:background="#00000000" 
      android:hint="@string/contact_name" 
      android:inputType="textPersonName" 
      android:maxLines="1" 
      android:textColor="#000000" 
      android:textSize="16sp" > 
     </EditText> 

     <Button 
      android:id="@+id/btnAddContact" 
      android:layout_width="28.5dp" 
      android:layout_height="28.5dp" 
      android:layout_alignParentRight="true" 
      android:layout_centerVertical="true" 
      android:layout_marginLeft="3dp" 
      android:layout_marginRight="3dp" 
      android:background="@drawable/add_button" 
      android:padding="0dp" /> 
    </RelativeLayout> 

    <ScrollView 
     android:id="@+id/svMessageView" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_above="@+id/rlNewMessage" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@id/rlAddContact" 
     android:background="#DBE2ED" > 

     <LinearLayout 
      android:id="@+id/llMessages" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="#DBE2ED" 
      android:isScrollContainer="true" 
      android:orientation="vertical" 
      android:paddingTop="11dp" > 
     </LinearLayout> 
    </ScrollView> 

    <RelativeLayout 
     android:id="@+id/rlNewMessage" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:background="@drawable/messagebar_background" 
     android:gravity="bottom" 
     android:padding="0dp" > 

     <Button 
      android:id="@+id/btnAttatchment" 
      android:layout_width="26dp" 
      android:layout_height="26dp" 
      android:layout_alignBottom="@+id/txtMessageBox" 
      android:layout_marginLeft="6dp" 
      android:background="@drawable/camera_icon" /> 

     <EditText 
      android:id="@+id/txtMessageBox" 
      android:layout_width="253dp" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="6dp" 
      android:layout_marginLeft="6dp" 
      android:layout_marginTop="8dp" 
      android:layout_toRightOf="@id/btnAttatchment" 
      android:background="@drawable/messagebox_background" 
      android:hint="@string/app_name" 
      android:inputType="textMultiLine" 
      android:maxLines="6" 
      android:minHeight="26dp" 
      android:textSize="17sp" > 
     </EditText> 

     <Button 
      android:id="@+id/btnSend" 
      android:layout_width="58dp" 
      android:layout_height="26dp" 
      android:layout_alignBottom="@id/txtMessageBox" 
      android:layout_alignParentRight="true" 
      android:layout_marginRight="6dp" 
      android:background="@drawable/send_button" 
      android:text="@string/send_button" 
      android:textAlignment="center" 
      android:textColor="#FFFFFF" 
      android:textSize="14sp" 
      android:textStyle="bold" /> 
    </RelativeLayout> 

</RelativeLayout> 

내 문제가 자동으로 바닥에 소프트 키보드가 사용자를 위해 화면에 나오는 모든 시간을 스크롤 할 수있는 ScrollView svMessageView을 받고있다 유형. 키보드가 나타납니다 RelativeLayout의 rlNewMessage 이동까지, 그리고 svMessageView의 바닥은 rlNewMessage의 상단에 충실 설정하고 그 작동,하지만 난에 의해 아래로 스크롤 svMessageView를 얻을 수있다 그 자체.

이미지 : http://imgur.com/8Kptge3

소프트 키보드를로드 한 후 (내가 원하는) : http://imgur.com/BcDcFPY

자세한 내용은 그림을 당신을 위해 필요한 경우

(I 원하지 무엇을) 소프트 키보드가로드 문제는 내게 알려주고 최대한 빨리 게시 할 것입니다.

답변

-1

Activity에 대한 귀하의 Manifest.xml이 추가 내가 그것을 테스트하지 못했지만, 당신이 scrollView.fullScroll (View.FOCUS_DOWN)을 시도 할 수

android:windowSoftInputMode="adjustNothing" 
+0

나는 내 질문에서 내가 원하는 것을 혼란스럽게 보았습니다. 지금은 앱에서 모든 것이 정상적으로 작동합니다. 소프트 키보드가 화면에 나타날 때마다 스크롤바를 맨 아래로 스크롤하는 데 필요한 코드를 알아야합니다 (마지막 메시지를 표시하기 위해). 나는 게시 할 스크린 샷을 얻었을뿐 아니라 아마도 내 질문을 명확히 할 것입니다. – vlllc

+0

@vlllc, 질문에 대해 운동 해 보셨습니까 ?? 왜냐하면 나는 비슷한 질문을 가지고있다.) –

0

날 다시 공급; 아마도 EditText 터치 리스너에.

+0

키보드를 여는 애니메이션 때문에이 작업이 너무 늦어 질 것이다. 당신이 이것을 위해 타이머를 사용할 수는 있지만, 프레임이 떨어지는 등의 이유로 매우 아프다. –

관련 문제