I need to remove scrollbars from the complete application.
I want to avoid the trouble of writing android:scrollbars="none" in all the ScrollViews defined in my application.
Now, here is what I have tried to do :
styles.xml
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:scrollViewStyle">@style/NoScrollbars</item>
<item name="android:scrollbarStyle">@style/NoScrollbars</item>
</style>
<style name="NoScrollbars" parent="android:Widget.ScrollView">
<item name="android:scrollbars">none</item>
</style>
Is there any way to make this happen ?
You can define a ScrollViewStyle and ListViewStyle in your Theme:
<style name="Theme.MyTheme" parent="android:Theme.Holo">
<item name="android:listViewStyle">@style/Widget.MyTheme.ListView</item>
<item name="android:scrollViewStyle">@style/Widget.MyTheme.ScrollView</item>
</style>
<style name="Widget.MyTheme.ListView" parent="android:Widget.ListView">
<item name="android:overScrollMode">never</item>
<item name="android:scrollbars">none</item>
</style>
<style name="Widget.MyTheme.ScrollView" parent="android:Widget.ScrollView">
<item name="android:overScrollMode">never</item>
<item name="android:scrollbars">none</item>
</style>
Then you have to define your Theme in you AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="nouman.app.example"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:targetSdkVersion="16" android:minSdkVersion="8"/>
<application
android:hardwareAccelerated="true"
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:theme="@style/Theme.MyTheme">
That's it. Done.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With