onConfigurationChanged 不适用于 API17
onConfigurationChanged is not working for API17
如果 table 从纵向倾斜到横向或反之亦然,我想触发一些东西。
然而 onConfigurationChanged
永远不会被触发。
我读过几年前堆栈溢出粉丝提出的几个问题,但 none 正在工作。
例如,在 Android 中添加 android:configChanges="orientation|screenSize"
。
下面是 AndroidManifest.xml、应用和调试日志,
谢谢
D/ViewRootImpl@d3690a3[MainActivity]: Relayout returned: old=[0,0][1920,1200] new=[0,0][1920,1200]
result=0x7 surface={true 3874265088} changed=true
D/OpenGLRenderer: eglCreateWindowSurface = 0xe8985120, 0xe6ec9808
D/ScrollView: onsize change changed
E/ViewRootImpl: sendUserActionEvent() returned.
I/Choreographer: Skipped 51 frames! The application may be doing too much work on its main thread.
D/ViewRootImpl@d3690a3[MainActivity]: MSG_RESIZED_REPORT: frame=[0,0][1920,1200] ci=[0,36][0,72] vi=
[0,36][0,72] or=2
D/ViewRootImpl@d3690a3[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 1 1
D/InputMethodManager: prepareNavigationBarInfo() DecorView@15f6fa0[MainActivity]
D/InputMethodManager: getNavigationBarColor() -855310
D/InputMethodManager: prepareNavigationBarInfo() DecorView@15f6fa0[MainActivity]
getNavigationBarColor() -855310
V/InputMethodManager: Starting input: tba=com.example.android.predictiongua ic=null mNaviBarColor
-855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
D/InputMethodManager: startInputInner - Id : 0
I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
D/InputTransport: Input channel constructed: fd=76
Input channel destroyed: fd=77
V/item: 7
V/item: 3
V/item: 8
<application
android:allowBackup="true"
android:icon="@mipmap/android_icon"
android:label="xxxxxx"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:configChanges="screenSize|keyboardHidden|orientation"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.android.xxxxxx"
minSdkVersion 17
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
implementation 'net.cachapa.expandablelayout:expandablelayout:2.9.2'
implementation 'com.github.aakira:expandable-layout:1.6.0@aar'
}
您应该将以下字符串放在 "activity" 标记之间,而不是 "application" 之间,尝试像下面这样使用它:
<application
android:allowBackup="true"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:configChanges="screenSize|keyboardHidden|orientation" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
如果 table 从纵向倾斜到横向或反之亦然,我想触发一些东西。
然而 onConfigurationChanged
永远不会被触发。
我读过几年前堆栈溢出粉丝提出的几个问题,但 none 正在工作。
例如,在 Android 中添加 android:configChanges="orientation|screenSize"
。
下面是 AndroidManifest.xml、应用和调试日志,
谢谢
D/ViewRootImpl@d3690a3[MainActivity]: Relayout returned: old=[0,0][1920,1200] new=[0,0][1920,1200]
result=0x7 surface={true 3874265088} changed=true
D/OpenGLRenderer: eglCreateWindowSurface = 0xe8985120, 0xe6ec9808
D/ScrollView: onsize change changed
E/ViewRootImpl: sendUserActionEvent() returned.
I/Choreographer: Skipped 51 frames! The application may be doing too much work on its main thread.
D/ViewRootImpl@d3690a3[MainActivity]: MSG_RESIZED_REPORT: frame=[0,0][1920,1200] ci=[0,36][0,72] vi=
[0,36][0,72] or=2
D/ViewRootImpl@d3690a3[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 1 1
D/InputMethodManager: prepareNavigationBarInfo() DecorView@15f6fa0[MainActivity]
D/InputMethodManager: getNavigationBarColor() -855310
D/InputMethodManager: prepareNavigationBarInfo() DecorView@15f6fa0[MainActivity]
getNavigationBarColor() -855310
V/InputMethodManager: Starting input: tba=com.example.android.predictiongua ic=null mNaviBarColor
-855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
D/InputMethodManager: startInputInner - Id : 0
I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
D/InputTransport: Input channel constructed: fd=76
Input channel destroyed: fd=77
V/item: 7
V/item: 3
V/item: 8
<application
android:allowBackup="true"
android:icon="@mipmap/android_icon"
android:label="xxxxxx"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:configChanges="screenSize|keyboardHidden|orientation"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.android.xxxxxx"
minSdkVersion 17
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
implementation 'net.cachapa.expandablelayout:expandablelayout:2.9.2'
implementation 'com.github.aakira:expandable-layout:1.6.0@aar'
}
您应该将以下字符串放在 "activity" 标记之间,而不是 "application" 之间,尝试像下面这样使用它:
<application
android:allowBackup="true"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:configChanges="screenSize|keyboardHidden|orientation" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>