思路:
1.默认键盘模式设置为adjustResize;
2.获取键盘的高度,设置给表情控件;
3.要显示表情控件时,先将键盘模式设置为ADJUST_NOTHING,表情控件设置为可见,再隐藏键盘;
4.要显示键盘时,先调用显示键盘,延时隐藏表情控件,并将键盘模式设置为ADJUST_RESIZE。
布局:
```java
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context=".MainActivity2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal">
<EditText
android:id="@+id/edit"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@null"
android:hint="我是输入框"
android:textColor="#00aaaa"
android:textSize="18sp" />
<ImageView
android:id="@+id/image_face"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/ic_smile" />
</LinearLayout>
<TextView
android:id="@+id/text_fake_face"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:background="#fafa00"
android:gravity="center"
android:text="假装是表情包"
android:visibility="gone"
tools:visibility="visible" />
</LinearLayout>
</RelativeLayout>
代码如下:
public class MainActivity2 extends AppCompatActivity {
private ImageView mFaceImage;
private View mFakeFaceView;
private InputMethodManager inputMethodManager;
private EditText mEdit;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(