java.lang.IllegalStateException: ActionBarContextView can only be used with android:layout_width=&qu
16lz
2022-01-26
- Steps to reproduce the problem (including sample code if appropriate).Implement a Dialog(Maybe an Activity also has this issue. But I have not tested it.) using a customized theme which does not extends any of a Android basic theme. Such as: <style name="MyDialogTheme"> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowNoTitle">true</item> <item name="android:windowIsFloating">true</item> <item name="android:windowContentOverlay">@null</item> <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item> <item name="android:windowIsTranslucent">true</item> <item name="android:windowFrame">@null</item> <item name="android:backgroundDimEnabled">false</item></style>Also add a EditText into the dialog layout.Run the dialog on a Tablet(I used Galaxy Tab 10.1 with Android OS 3.1). Type some words into the EditText. Then double click the typed words.- What happened.Crashed with this exception message: java.lang.IllegalStateException: ActionBarContextView can only be used with android:layout_width="match_parent" (or fill_parent) at com.android.internal.widget.ActionBarContextView.onMeasure(ActionBarContextView.java:257) at android.view.View.measure(View.java:10840) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4351) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1284) at android.widget.LinearLayout.measureVertical(LinearLayout.java:613) at android.widget.LinearLayout.onMeasure(LinearLayout.java:519) at android.view.View.measure(View.java:10840) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4351) at android.widget.FrameLayout.onMeasure(FrameLayout.java:267) at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2042) at android.view.View.measure(View.java:10840) at android.view.ViewRoot.performTraversals(ViewRoot.java:884) at android.view.ViewRoot.handleMessage(ViewRoot.java:2017) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:132) at android.app.ActivityThread.main(ActivityThread.java:4028) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:491) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602) at dalvik.system.NativeStart.main(Native Method)- What you think the correct behavior should be.It should not crash and show OS selection UI to allow user to select words.It works before OS 3.0. So it is a backward compatibility issue.If it really need to throw a exception, at least we should get some information about why it happened more clearly., Aug 3, 2011
If I modify the style as below. It will not crash.<style name="MyDialogTheme" parent="@android:style/Theme.Dialog"> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowNoTitle">true</item> <item name="android:windowIsFloating">true</item> <item name="android:windowContentOverlay">@null</item> <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item> <item name="android:windowIsTranslucent">true</item> <item name="android:windowFrame">@null</item> <item name="android:backgroundDimEnabled">false</item></style>
更多相关文章
- 代码中设置drawableleft
- android 3.0 隐藏 系统标题栏
- Android开发中activity切换动画的实现
- Android(安卓)学习 笔记_05. 文件下载
- Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
- 技术博客汇总
- android 2.3 wifi (一)
- AndRoid Notification的清空和修改
- Android中的Chronometer