【发布时间】:2017-02-16 11:17:01
【问题描述】:
我唯一想做的就是顶部有一个editText,之后会有一个ImageView。 现在在底线会有一些按钮(例如表情符号),并且这个底部只会在出现时被软键盘向上推。
我通过附上 Facebook 的这个布局更清楚地说明了这一点。 required output
我已经解决了所有这些 SO 问题,也尝试了他们的答案,但没有运气。可能是我做错了什么。
Android: Resize only parts of view with soft keyboard on screen
Android: How do I prevent the soft keyboard from pushing my view up?
android : How to prevent resizing the window when displaying the virtual keyboard
我的 XML 代码
<ScrollView
android:id="@+id/scrollOnPost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:isScrollContainer="false"
android:fillViewport="true"
android:layout_below="@+id/header_layout">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="4"
android:layout_gravity="bottom"
android:gravity="bottom">
<EditText
android:id="@+id/ed_post"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ImageView
android:id="@+id/img_posted_list_row"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2.7"
android:adjustViewBounds="true"
android:src="@mipmap/ic_launcher"
android:scaleType="fitCenter"
android:background="@color/red"/>
</LinearLayout>
</ScrollView>
<ImageButton
android:id="@+id/imgBtn_Emoji"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:src="@drawable/smile_face"
android:background="@drawable/button_pressed_white"
/>
我发现我的软键盘总是将整个布局向上推,而不仅仅是底部的表情符号。谢谢。
【问题讨论】:
-
查看此链接可能对您有所帮助:stackoverflow.com/questions/17410499/…
-
感谢库纳尔的链接。我已经在清单中同时尝试了 "adjustResize" 、 "adjustPan" 和两者,但结果不是我需要的。但问题与我的问题完全相同。再次感谢。
-
@ Md. Asaduzzaman Noor 我尝试在我的代码中添加您的布局,然后我可以找到什么解决方案
-
好的,只需将我的整个代码包装到一个 RelativeLayout 中,然后将您想要测试的任何键盘模式放入清单中。
-
你检查了吗?如果对您有帮助,请将其标记为答案并点赞
标签: android layout android-edittext scrollview android-softkeyboard