Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show an text editing box "over" the screen?

I have an application that has a primary layout of portrait (it is fixed as portrait), and there is one place to type in text. I would like to launch like a popup window in landscape orientation with the background image fogged out. I know there is a Popup Widget, but any ideas for rotating the text edit box would be great. Rotating it into a portrait view (text box only) when the keyboard is slid out would also work, as would showing a new screen with the text box on keyboard slide.

like image 243
Chrispix Avatar asked Jan 20 '09 08:01

Chrispix


People also ask

How do you make a text box appear over a picture?

Use WordArt to add text on top of a photo On the Insert tab, in the Text group, click WordArt, click the style of text you want, and then type your text. Click the outside edge of the WordArt to select it, drag the text over your photo and then, if you want, rotate the text to the angle that works best for your photo.

How do you bring a text box to the front?

Click the WordArt, shape, or text box that you want to move up or down in the stack. On the Drawing Tools Format tab, click either Bring Forward or Send Backward. You'll have the choice of moving the object up one layer (Bring Forward) or to the top of the stack (Bring to Front).

How do you overlay text boxes in Word?

If so, I think you can right click on the small “Arrow” icon of the table, select “Table Properties”. Then under Table wrapping, select Around. After that go to Positioning > Check option “Allow overlap” and Ok to save. Then repeat the processes for another table of cells.

How do I put a text box on top of another text box?

Click the "Text Wrapping" tab in this window and select the position option "In front of text." Click "OK" to return to your document. The text box now sits on top of the text in the Word file.


1 Answers

The easiest solution to your problem is to display your EditText within a separate dialog themed Activity that you launch from within your main (portrait-fixed) Activity.

The EditText Activity shouldn't have its orientation fixed, so it will rotate as you'd expect when you slide out the keyboard.

Creating the Text Entry Activity

Create a new Activity the contains only the EditText View and anything else you want to include (probably OK / Cancel buttons and maybe a label?). Within the manifest set its theme to Theme.Dialog.

<activity android:name="TextEntryActivity" 
          android:label="My Activity" 
          android:theme="@android:style/Theme.Dialog"/>

Fogging or Blurring the Activities behind a dialog is done by modifying the Window properties of the foreground Activity (your text entry dialog). Within it's onCreate method use getWindow().setFlags to apply blurring to any background Activities.

getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,  
                     WindowManager.LayoutParams.FLAG_BLUR_BEHIND);

Launching and Reading Entered Values from the Text Entry Activity

Use startActivityForResult to launch the text entry Activity. Within that Activity call setResult to return the text string entered within the returned intent using the techniques described in this post.

Override the onActivityResult method to listen for the result from the sub Activity.

Triggering Launch on Keyboard Exposed

You can launch the text entry Activity whenever you want, but if you want to always display it when the keyboard is exposed you can capture this event explicitely.

Start by adding the android:configChanges attribute to the portrait Activity's manifest entry. It should be registered to listen for keyboardHidden.

android:configChanges="keyboardHidden"

Within that Activity, override onConfigurationChanged to launch the text entry Activity.

@Override
public void onConfigurationChanged(Configuration newConfig) {  
  Intent i = new Intent(this,TextEntryActivity.class);    
  startActivityForResult(i, STATIC_INTEGER_VALUE);
}

You may want to check to confirm the keyboard is being exposed (rather than hidden) using the newConfig variable before launching the text entry Activity.

You may also want to use the same technique to automatically return from the text entry activity when the keyboard is hidden.

like image 119
Reto Meier Avatar answered Sep 26 '22 06:09

Reto Meier