[Android] Fix scrolling in preferences
Geoffrey Métais
git at videolan.org
Tue Sep 12 13:46:15 CEST 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Sep 12 13:45:52 2017 +0200| [4605ecf9ac752071782982fb3d712eedfa9ce042] | committer: Geoffrey Métais
Fix scrolling in preferences
> https://code.videolan.org/videolan/vlc-android/commit/4605ecf9ac752071782982fb3d712eedfa9ce042
---
vlc-android/res/layout/preferences_activity.xml | 14 +++++---------
.../vlc/gui/preferences/BasePreferenceFragment.java | 7 ++++---
.../videolan/vlc/gui/preferences/PreferencesActivity.java | 10 +++++-----
3 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/vlc-android/res/layout/preferences_activity.xml b/vlc-android/res/layout/preferences_activity.xml
index 5e25f594a..be6a91f3b 100644
--- a/vlc-android/res/layout/preferences_activity.xml
+++ b/vlc-android/res/layout/preferences_activity.xml
@@ -6,14 +6,10 @@
android:layout_height="match_parent" >
<include layout="@layout/toolbar"/>
- <android.support.v4.widget.NestedScrollView
- android:id="@+id/nestedscrollview"
- android:layout_width="match_parent"
+
+ <FrameLayout
+ android:id="@+id/fragment_placeholder"
+ android:layout_width="fill_parent"
android:layout_height="match_parent"
- vlc:layout_behavior="@string/appbar_scrolling_view_behavior" >
- <FrameLayout
- android:id="@+id/fragment_placeholder"
- android:layout_width="fill_parent"
- android:layout_height="match_parent" />
- </android.support.v4.widget.NestedScrollView>
+ vlc:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
diff --git a/vlc-android/src/org/videolan/vlc/gui/preferences/BasePreferenceFragment.java b/vlc-android/src/org/videolan/vlc/gui/preferences/BasePreferenceFragment.java
index 69151f821..086f0181c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/preferences/BasePreferenceFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/preferences/BasePreferenceFragment.java
@@ -50,9 +50,10 @@ public abstract class BasePreferenceFragment extends PreferenceFragmentCompat {
public void onStart() {
super.onStart();
final PreferencesActivity activity = (PreferencesActivity)getActivity();
- activity.scrollUp();
- if (activity != null && activity.getSupportActionBar() != null && getTitleId() != 0) {
- activity.getSupportActionBar().setTitle(getString(getTitleId()));
+ if (activity != null) {
+ activity.expandBar();
+ if (activity.getSupportActionBar() != null && getTitleId() != 0)
+ activity.getSupportActionBar().setTitle(getString(getTitleId()));
}
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesActivity.java b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesActivity.java
index 599ec9743..b19f5f8d2 100644
--- a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesActivity.java
@@ -24,7 +24,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
-import android.support.v4.widget.NestedScrollView;
+import android.support.design.widget.AppBarLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
@@ -57,7 +57,7 @@ public class PreferencesActivity extends AppCompatActivity implements PlaybackSe
private PlaybackService.Client mClient = new PlaybackService.Client(this, this);
private PlaybackService mService;
- private NestedScrollView nestedScrollView;
+ private AppBarLayout mAppBarLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -73,11 +73,11 @@ public class PreferencesActivity extends AppCompatActivity implements PlaybackSe
.replace(R.id.fragment_placeholder, new PreferencesFragment())
.commit();
}
- nestedScrollView = (NestedScrollView) findViewById(R.id.nestedscrollview);
+ mAppBarLayout = (AppBarLayout) findViewById(R.id.appbar);
}
- void scrollUp() {
- nestedScrollView.scrollTo(0,0);
+ void expandBar() {
+ mAppBarLayout.setExpanded(true);
}
@Override
More information about the Android
mailing list