Bug P4
Status Update
Comments
vi...@google.com <vi...@google.com>
vi...@google.com <vi...@google.com> #2
I face with the same problem. I have different pageMargin in landscape and portrait and when viewpager is scrolled for the more than first position, after rotating device it is shifted.
I beleive the problem is inside onSizeChanged that is called after onConfigurationChanged, it has following code:
if (w != oldw) {
recomputeScrollPosition(w, oldw, mPageMargin, mPageMargin);
}
w always not equals oldw when changing orientation, so recomputeScrollPosition is called, but whit the same values for margin and oldMargin.
This should be fixed.
I beleive the problem is inside onSizeChanged that is called after onConfigurationChanged, it has following code:
if (w != oldw) {
recomputeScrollPosition(w, oldw, mPageMargin, mPageMargin);
}
w always not equals oldw when changing orientation, so recomputeScrollPosition is called, but whit the same values for margin and oldMargin.
This should be fixed.
Description
Version used:
Theme used:
Devices/Android versions reproduced on:
- Relevant code to trigger the issue.
- A screenrecord or screenshots showing the issue (if UI related).
My gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.1"
defaultConfig {
applicationId "com.example.myswipe"
minSdkVersion 15
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
//implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
//implementation 'androidx.legacy:legacy-support-v4:1.0.0'
//implementation 'androidx.annotation:annotation:'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
my imports:
package com.example.myswipe;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import androidx.core.view.ViewPager; #Not working
import androidx.drawerlayout.widget.DrawerLayout; #Not working
My mainactivity file: