-1

I am able to add a done button to soft keyboard but I also want to add a Del Button is this possible if yes please tell me how ?

enter image description here

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Chunhua
  • 41
  • 1
  • 5

1 Answers1

2

Create an sample.xml layout file

<?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>

Create the Sample.java Activity file

public class Sample extends Activity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.sample);
    }
}

Make sure you add android:windowSoftInputMode="adjustResize" in the manifest file like below.

<activity android:name=".Sample"
           android:windowSoftInputMode="adjustResize">
</activity>

enter image description here

Naz141
  • 433
  • 1
  • 8
  • 31
  • Not only one Activity will need to customer soft keypad , I hope it will be used in other Activity. – Chunhua Nov 09 '17 at 07:22