【发布时间】:2016-08-24 05:34:55
【问题描述】:
我正在开发聊天应用程序,其中 Edittext 和发送按钮位于底部。 Activity 是全屏的,隐藏的导航和状态栏。 当键盘成为焦点时,我需要按下 edittext 并向上发送按钮。
- 我尝试设置 android:windowSoftInputMode="adjustResize" 但没有成功。
- 我尝试使用 https://github.com/madebycm/AndroidBug5497Workaround 引用的 AndroidBug5497Workaround.assistActivity(this) 类,但没有成功。
以下是我的活动主题和活动中隐藏栏并全屏显示的代码:
decorView = getWindow().getDecorView();
uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
主题:
<style name="AppTheme_DarkStatus" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryveryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowContentTransitions">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
XML :
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/include_view"
android:isScrollContainer="true"
android:background="@android:color/white">
<com.handmark.pulltorefresh.library.PullToRefreshListView
xmlns:ptr="http://schemas.android.com/apk/res-auto"
android:id="@+id/lv_chat"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/rl_send"
android:divider="@null"
android:fadeScrollbars="false"
android:fadingEdge="none"
android:overScrollMode="never"
android:scrollbars="none"
ptr:ptrHeaderSubTextColor="@color/c_input_text_color"
ptr:ptrHeaderTextColor="@color/c_input_text_color"
ptr:ptrOverScroll="false"
ptr:ptrPullLabel="Pull to refresh"
ptr:ptrRefreshLabel="Loading..."
ptr:ptrReleaseLabel="Release to refresh"
ptr:ptrRotateDrawableWhilePulling="true"
ptr:ptrShowIndicator="false" >
</com.handmark.pulltorefresh.library.PullToRefreshListView>
<RelativeLayout
android:id="@+id/rl_send"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/c_white"
android:gravity="center" >
<View
android:id="@+id/view_dummy"
android:layout_width="match_parent"
android:layout_height="@dimen/d_diff_p5dp"
android:background="@color/c_text_light_color" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/view_dummy"
android:layout_toLeftOf="@+id/btn_send"
android:layout_marginRight="@dimen/d_diff_5dp"
android:layout_marginLeft="@dimen/d_diff_10dp"
android:layout_marginTop="@dimen/s_diff_7sp"
android:layout_marginBottom="@dimen/s_diff_7sp"
android:background="@drawable/opawhite_rectcorner_all" android:id="@+id/relativeLayout">
<EditText
android:id="@+id/et_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/d_diff_1dp"
android:background="@null"
android:focusableInTouchMode="true"
android:maxHeight="100dp"
android:hint="Type here..."
android:maxLength="150"
android:textSize="@dimen/s_diff_16sp"
android:padding="@dimen/s_diff_6sp"
android:textColorHint="@color/c_input_text_color"
android:textColor="@color/c_black" />
</RelativeLayout>
<Textview
android:id="@+id/btn_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/c_white"
android:text="Send"
android:padding="@dimen/d_diff_5dp"
android:layout_marginRight="@dimen/d_diff_5dp"
android:gravity="center"
android:textColor="@color/c_orange_main"
android:textSize="@dimen/s_diff_16sp"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"/>
</RelativeLayout>
</RelativeLayout>
我想在键盘上方显示编辑文本和发送按钮,但它与编辑文本重叠。
谢谢!
【问题讨论】:
-
有人可以看看吗?
标签: android-edittext android-softkeyboard android-fullscreen