Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): hide scrollbars in WebView #14031

Merged
merged 3 commits into from
May 13, 2024
Merged

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented May 8, 2024

Android WebView allows you to hide the horizontal/vertical scrollbar but still keeping it scrollable.

Test:

var html = '<!DOCTYPE html><html><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1"></head><body>';
html += "<div style='height:400px;width:400px;background-color:black'></div>";
html += "</body></html>";
var win = Ti.UI.createWindow({
	layout: "vertical"
})

var text = ["default", "hide vertical", "hide horizontal", "hide all"];
for (var i = 0; i <= 3; ++i) {
	var lbl = Ti.UI.createLabel({
		text: text[i]
	});
	win.add(lbl);
	var www = Ti.UI.createWebView({
		html: html,
		height: 140,
		width: 300,
		scrollbars: i,
		enableZoomControls: false,
		bottom: 5
	})
	win.add(www);
}
win.open();

console.log(Ti.UI.Android.WEBVIEW_SCROLLBARS_DEFAULT)
console.log(Ti.UI.Android.WEBVIEW_SCROLLBARS_HIDE_VERTICAL)
console.log(Ti.UI.Android.WEBVIEW_SCROLLBARS_HIDE_HORIZONTAL)
console.log(Ti.UI.Android.WEBVIEW_SCROLLBARS_HIDE_ALL)

Run the code and scroll the black div in the webview.

Screencast_20240508_231349.mp4

@cb1kenobi
Copy link
Contributor

I'm testing this and I don't see any scrollbars in any of the WebViews. I see the white borders just like yours, but no scroll indicators. I changed the window background color to make sure I wasn't missing them, but I dunno why I can't see them.

I am tested on both Android 13 and 14 emulators. Maybe it's an emulator issue?

@m1ga
Copy link
Contributor Author

m1ga commented May 13, 2024

Oh, I'm running in dark mode. Maybe they are black in your emulator an just not visible over the black div. Is the functionality working? I left the white border on the side so you can see if it is scrolling

Copy link
Contributor

@cb1kenobi cb1kenobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, it was totally dark mode! I changed the html background to green and now I can see the scrollbars!

APPROVED!

@cb1kenobi cb1kenobi merged commit 6642ed1 into master May 13, 2024
6 checks passed
@m1ga m1ga deleted the androidWebViewScrolling branch May 13, 2024 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants