У меня есть работа по редактированию некоторого текста с верхней панелью в виде EditText в многострочном режиме внутри scrollview. Внизу еще один вид с двумя кнопками. То, что я хотел достичь, - это отредактировать текст, который нижний план будет ниже мягкой клавиатуры. Это легко использовать с помощью android: windowSoftInputMode = "adjustPan" в манифесте. Проблема в том, что edittext становится достаточно большим с несколькими строками, при редактировании верхней панели он исчезает. Это происходит только при использовании режима adjustPan. Но самое худшее, и я думаю, что это ошибка, когда курсор находится в конце представления edittext и прокручивается с помощью джойстика D-Pad, все макет тянут вверх.Android EditText Multiline with SoftInputMode adjustPan
Это экран без фокуса на EditText: http://i.stack.imgur.com/pFadV.png
Когда ошибка происходит с прокруткой, это происходит: http://i.stack.imgur.com/eS8PP.png
Моя раскладка следующая:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/BackgroundGray"
android:gravity="top|center"
android:orientation="vertical"
android:windowSoftInputMode="adjustPan" >
<RelativeLayout
android:id="@+id/top_bar"
android:layout_width="fill_parent"
android:layout_height="45dip"
android:layout_alignParentTop="true"
android:background="@drawable/top_bar"
android:focusable="true"
android:focusableInTouchMode="true" >
<ImageView
android:id="@+id/bar_item_priority"
android:layout_width="4dip"
android:layout_height="34dip"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:contentDescription="@string/priority" />
<EditText
android:id="@+id/bar_title"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="6dip"
android:background="@android:color/transparent"
android:fadingEdge="vertical"
android:gravity="center_vertical|left"
android:hint="@string/default_title"
android:inputType="text|textCapSentences"
android:paddingLeft="10dip"
android:textColor="#f3f3f3"
android:textColorHint="#20ffffff"
android:textSize="20dip"
android:textStyle="bold" >
</EditText>
</RelativeLayout>
<View
android:id="@+id/main_top_bar_shadow"
android:layout_width="fill_parent"
android:layout_height="1dip"
android:layout_below="@+id/top_bar"
android:background="@color/TopBarShadow" />
<LinearLayout
android:id="@+id/meta_bar"
android:layout_width="fill_parent"
android:layout_height="25dip"
android:layout_below="@+id/main_top_bar_shadow"
android:background="#313435"
android:descendantFocusability="blocksDescendants" >
<TextView
android:id="@+id/meta_date_modified"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|left"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:paddingTop="6dip"
android:shadowColor="#1d1d1d"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"
android:text="@string/default_date"
android:textColor="#9d9d9d"
android:textSize="12dip"
android:textStyle="bold" >
</TextView>
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/bottom_bar"
android:layout_below="@+id/meta_bar"
android:fillViewport="true"
android:scrollbarSize="2dip"
android:scrollbarThumbHorizontal="@drawable/scrollbar"
android:scrollbarThumbVertical="@drawable/scrollbar"
android:scrollbars="vertical" >
<view
android:id="@+id/note"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:capitalize="sentences"
class="home.greven.notes.NoteEditor$LinedEditText"
android:fadingEdge="vertical"
android:gravity="top"
android:paddingBottom="8dip"
android:paddingLeft="11dip"
android:paddingRight="11dip"
android:paddingTop="8dip"
android:textSize="16sp" >
</view>
</ScrollView>
<View
android:id="@+id/bottom_bar_shadow"
android:layout_width="fill_parent"
android:layout_height="1dip"
android:layout_above="@+id/bottom_bar"
android:background="@color/TopBarShadow"
android:focusable="false"
android:focusableInTouchMode="false" />
<LinearLayout
android:id="@+id/bottom_bar"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_alignParentBottom="true"
android:background="@drawable/bottom_buttons_bar"
android:descendantFocusability="blocksDescendants" >
<Button
android:id="@+id/bottom_bar_button_plaintext"
style="@style/NoteEditorButtonText"
android:layout_width="0.0dip"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="4dip"
android:layout_weight="0.5"
android:background="@drawable/small_blue_buttonstates"
android:text="@string/plain_text" />
<Button
android:id="@+id/bottom_bar_button_checklist"
style="@style/NoteEditorButtonText"
android:layout_width="0.0dip"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="4dip"
android:layout_weight="0.5"
android:background="@drawable/small_gray_buttonstates"
android:onClick="toChecklist"
android:text="@string/checklist" />
</LinearLayout>
</RelativeLayout>
Если я используйте adjustResize в android: windowSoftInputMode все работает хорошо, но тогда нижняя панель будет видна при редактировании, что-то, чего я не хотел. Я думаю, что эта проблема прокрутки - ошибка Android. Любая помощь будет очень оценена!
Спасибо за ответ, но он по-прежнему делает странное поведение при прокрутке с D-Pad. – greven
На самом деле я не тестировал этот код в D-pad, но другие устройства не показывают то же самое. –
Единственная проблема, с которой я сталкиваюсь, - это прокрутка с помощью D-Pad и только при отображении софт-клавиатуры. Кроме этого, да, это решение работает, но ошибка все еще существует. – greven