答案 0 :(得分:1)
创建sample.xml布局文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:gravity="left"
android:background="#e4e4e4"
android:layout_width="0dp"
android:layout_weight="8"
android:layout_height="match_parent" />
<LinearLayout
android:orientation="vertical"
android:layout_weight="2"
android:layout_width="0dp"
android:layout_height="wrap_content">
<Button
android:text="Done"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:text="Del"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
创建Sample.java活动文件
public class Sample extends Activity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sample);
}
}
确保在清单文件中添加android:windowSoftInputMode="adjustResize"
,如下所示。
<activity android:name=".Sample"
android:windowSoftInputMode="adjustResize">
</activity>