Custom keyboard with custom row - android

I have to draw custom view (image view + edit text) on top of keyboard in my custom keyboard app. how can i draw this?
I used many custom keyboard example but using that i was just able to draw custom keys (Alphabets/Numeric).
Please help me
Edit-
I tried to create with custom keyboard and added a sample view above keyboardview but when i run the app it is not visible
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="#+id/layoit_row"
android:layout_width="match_parent"
android:layout_height="100dp">
<ImageView
android:id="#+id/ivKeyboard"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentLeft="true"
android:padding="10dp"
android:scaleType="fitEnd"
android:src="#drawable/ic_launcher_background" />
<EditText android:id="#+id/et_box"
android:layout_toRightOf="#+id/ivKeyboard"
android:layout_width="match_parent"
android:layout_height="100dp"
android:text="Asjhish"/>
</RelativeLayout>
<android.inputmethodservice.KeyboardView
android:id="#+id/keyboard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/layoit_row"
android:keyPreviewLayout="#layout/preview" />

Related

Add a view overlay on map view android

I am using the MapView from the Google Map Android SDK in full screen, but I have a requirement to display another transparent full view over the mapview. The overlay displays as expected, however, the map can be controlled (markers can be clicked, map can be moved) despite the overlay being on it.
How can I ensure the overlay prevents the map from being controllable when in view?
Add following on your overlay view parent layout.
android:focusable="true"
android:focusableInTouchMode="true"
android:clickable="true"
Remember you need to place above line on parent layout of overlay view
You can do this by making your overlay clickable. Add below code to the xml of your overlayview.
android:clickable="true"
For example I use the following code to add a button to the page
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<fragment
android:id="#+id/location_map"
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#359c5e"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:padding="8dp"
android:layout_margin="5dp"
android:text="#string/go"
android:textColor="#ffffff" />
</RelativeLayout>

Handwriting Soft Keyboard Android

I am working on an android keyboard app which should show drawing canvas as instead of normal key based soft keyboard. Just like Google's Handwriting keyboard I don't want to implement candidate view or do handwriting recognition. My keyboard will just take the text in canvas and send it as an image.
However after researching a lot, I am still not able to show canvas view in stead of Keyboard view. I followed:
https://code.tutsplus.com/tutorials/create-a-custom-keyboard-on-android--cms-22615
But this adds a keyboard view with a keyboard. I don't want to have a numeric or character keyboard. I just want the keyboard to show an empty canvas where I can draw and once done it should send that image.
I have also tried to put in a layout like this:
<?xml version="1.0" encoding="utf-8"?>
<android.inputmethodservice.KeyboardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/keyboard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:keyBackground="#drawable/square_rounded"
android:background="#ffffff">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="#+id/mainLinearLayout">
<RelativeLayout
android:id="#+id/keyboardLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="100dp"
android:layout_height="50dp"
android:text="Cancel"
android:layout_alignParentLeft="true">
</Button>
<Button
android:layout_width="100dp"
android:layout_height="50dp"
android:text="Done"
android:layout_alignParentRight="true">
</Button>
<LinearLayout
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</android.inputmethodservice.KeyboardView>
and then tried loading it like:
kv = (KeyboardView)getLayoutInflater().inflate(R.layout.draw_signature, null);
// keyboard = new Keyboard(this, R.xml.drawing_keyboard);
// kv.setKeyboard(keyboard);
kv.setOnKeyboardActionListener(this);
kv.setPreviewEnabled(false);
return kv;
Any help or a tutorial link would be appreciated.
Thanks,
Anand

Push only the bottom part up when Soft keyboard appears

The only thing I am trying do that there will be an editText at the top and after that there will be an ImageView.
Now at the bottom line there will be some buttons (ex. emojis) and this bottom part will only be pushed up by the soft keyboard whenever it will appear.
I am making it more clear by attaching this layout of Facebook.
required output
I have gone through all these SO questions and also tried their answers but no luck. May be I am doing something wrong.
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
My XML code
<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"
/>
All I getting that my soft keyboard always pushing the whole layout up not just the emoji at the bottom. Thanks.
Dude it worked
manifest :
<activity android:name=".TestActivity"
android:windowSoftInputMode="adjustResize"/>
xml :
<?xml version="1.0" encoding="utf-8"?>
<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"
xmlns:android="http://schemas.android.com/apk/res/android">
<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:scaleType="fitCenter"
android:background="#color/colorPrimary"/>
<ImageButton
android:id="#+id/imgBtn_Emoji"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:src="#mipmap/call"
/>
</LinearLayout>
I guess you want only the editText to push up when keyboard is visible(Correct me if i am wrong) for that i have got an idea i don't know if it will work or not you can try it out if you find it logical
Idea is to first check if keyboard is visible or not and secondly if visible get its height and programatically give your layout a marginBottom which will be equal to the height of keyboard(using layoutParams).
check this links for implementing above idea :
How to capture the "virtual keyboard show/hide" event in Android?
Is there any way in android to get the height of virtual keyboard of device
How to set RelativeLayout layout params in code not in xml

Overlap a view in android

The main layout have four widgets- one EditText and three TextView as given below.
I want to add suggestion-list view dynamically as given below:
How to do it?
You can use AutoCompleteTextView. Described in http://developer.android.com/guide/topics/ui/controls/text.html.
Probably Custom adapter will help you to make two suggestions lists. Take a look at this Autocompletetextview with custom adapter and filter. I guess you need to create divider in custom adapter.
As described in comments. Just Make listview visible when you need to show suggestions. Or paste in eclipse and remove android:visibility="gone" attribute and you will see gray listview over textviews.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="#+id/search"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/tv_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/search"
android:text="text1" />
<TextView
android:id="#+id/tv_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/tv_1"
android:text="text2" />
<ListView
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_below="#id/search"
android:background="#android:color/darker_gray"
android:visibility="gone" />
</RelativeLayout>
There is a class already built into android which gives you think functionality.
It's called AutoCompleteTextView

Android layout design: image above form above button. When the keyboard appears my layout is screwed

In my application I want to have a layout like this:
I did it with a Relative Layout holding an ImageView, TableLayout and a Button. The problem is that when I open the keyboard to modify a EditText the keyboard is on top of the EditText, so the user can't see what he is writing. I want the layout to be like this when the keyboard is shown:
The user should be able to scroll up the view to see the whole image while the keyboard is shown, even if he doesn't see the EditText then, because he wants to copy some data of the image into the EditTexts. I tried to do it like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="vertical" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/buttonEditStop"
android:padding="10dip" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/stopImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:clickable="true"
android:contentDescription="#string/entry_img"
android:onClick="ImageClick" />
<TableLayout
android:id="#+id/formLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/stopImg"
android:layout_marginRight="10dp" >
...
</TableLayout>
</RelativeLayout>
</ScrollView>
<ImageButton
android:id="#+id/buttonEditStop"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:contentDescription="#string/edit_stop"
android:onClick="EditButtonClicked"
android:src="#drawable/ic_menu_edit" />
Using this code my whole layout is screwed. I see the form on top of the image, followed by a ImageButton with the image that should be seen in the imageView.
Anyone knows how I can get a layout like the one I want?
Thanks!
To avoid the EditText to be overlapped I had to use
android:windowSoftInputMode="adjustPan"
in my manifest.

Categories

Resources