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.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- 放在input的text下文本一直出现一个/(即使还没输入任何值)是什么情况
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
The easiest solution to your problem is to display your
EditText
within a separatedialog
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
.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.Launching and Reading Entered Values from the Text Entry Activity
Use
startActivityForResult
to launch the text entry Activity. Within that Activity callsetResult
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 forkeyboardHidden
.Within that Activity, override
onConfigurationChanged
to launch the text entry Activity.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.