Hi,
I am implementing an input method service that uses as input view a
class extending a SurfaceView.
This is needed as a dedicated drawing surface for input in vertical
orientation.
However, although in fullscreen mode, neither the ExtractEditText box
nor the button appears on top.
Could it be that the system's fullscreen mode does not work properly
with a SurfaceView ?
Thanks a lot,
zdena984
Here is my skeleton code:
1) Input Method Service
-----------------------------------------------------
package android.input;
import android.content.res.Configuration;
import android.graphics.Color;
import android.inputmethodservice.InputMethodService;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
public class IMETest extends InputMethodService {
private LinearLayout inputViewGroup;
private IMEView imeView;
private Button okButton;
/* (non-Javadoc)
* @see
android.inputmethodservice.InputMethodService#onCreateInputView()
*/
@Override
public View onCreateInputView() {
if (inputViewGroup == null) {
inputViewGroup = new LinearLayout(this);
inputViewGroup.setOrientation(LinearLayout.VERTICAL);
inputViewGroup.setBackgroundColor(Color.BLACK);
imeView = new IMEView(this);
inputViewGroup.addView(imeView, new
LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT, 1.0f));
LinearLayout textLayout = new LinearLayout(this);
textLayout.setOrientation(LinearLayout.HORIZONTAL);
textLayout.setGravity(Gravity.CENTER_VERTICAL |
Gravity.RIGHT);
okButton = new Button(this);
okButton.setText("OK");
okButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
requestHideSelf(0);
}
});
textLayout.addView(okButton, new
LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
inputViewGroup.addView(textLayout, new
LayoutParams(LayoutParams.MATCH_PARENT, 70));
}
return inputViewGroup;
}
@Override
public View onCreateCandidatesView() {
return null;
}
@Override
public boolean onEvaluateFullscreenMode() {
return true;
}
@Override
public boolean onEvaluateInputViewShown() {
return ((getResources().getConfiguration().orientation
& Configuration.ORIENTATION_PORTRAIT)
== Configuration.ORIENTATION_PORTRAIT);
}
}
2) Rudimentary SurfaceView:
--------------------------------------------
package android.input;
import android.view.SurfaceView;
public class IMEView extends SurfaceView {
public IMEView(IMETest imeTest) {
super(imeTest);
}
}
3) AndroidManifest.xml
------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.testing"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/
app_name">
<activity android:name=".IMEFullscreenTest"
android:windowSoftInputMode="adjustResize"
android:label="IMETestApp">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="android.input.IMETest"
android:label="Surface IME"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
<meta-data android:name="android.view.im"
android:resource="@xml/method" />
</service>
</application>
<uses-sdk android:minSdkVersion="9" />
</manifest>
4) input.xml
-------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<android.input.IMEView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/surfaceView"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"/>
5) res/xml/method.xml
--------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<!--
/**
* Copyright (c) 2008, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
* See the License for the specific language governing permissions
and
* limitations under the License.
*/
-->
<!-- The attributes in this XML file provide configuration information
-->
<!-- for the Search Manager. -->
<input-method xmlns:android="http://schemas.android.com/apk/res/
android" />
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en