is there a way to have fixed headers on android - android

If I use position:fixed for a header, it stays fixed however on android there is a bug where if you have any fixed position divs present when you focus an input element, the page does crazy scrolling jumping about all over the place when you type.
so, I thought the solution was something like iscroll, so i can keep everything to position: absolute instead.
However, even the new iscroll5 doesnt allow android to use any SELECT inputs within an iscroll, it just doesnt focus them. On top of this, any input elements get the input overlay appearing but not over the top of the input, another bug of android..
Is there any way to get fixed header/ other elements that works on android? is there a different script to iscroll which can use form elements without hassle?

in IScroll 5 you can add the parameter preventDefaultException for enabling click of any input and for this example any element having the class .placeholder, .label. Example :
this.scroll = new IScroll('#wrapper',
{
preventDefaultException: {
tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT|LABEL|SPAN)$/,
className:/^(placeholder|label)$/
}
});

Related

Android keyboard overlapping input fields only scroll after type input

I have the similar problem described in this question. I've tried android:windowSoftInputMode="adjustResize" but it's not scrolled automatically scroll; it's only scrolling after type something into the input. I need that it scroll input on top immediately after keyboard showing, so no need to type anything into the input before I can see the input.
The problem does not happen on Android 4.4, Android 5. Android 6 and onward it does happen. I use Cordova 6.
(Pictures are taken from Android keyboard overlapping input fields, view doesn't scroll automatically for demonstration purpose)

wild scroll input android

I am working on a responsive website, which has a different stylesheet for either mobile or desktop. Everything looks nice and works great, until text inputs are interacted with on mobile. They show up as they should. But once clicked (ehrm.. touched), I found that the browser in Android starts scrolling like crazy, and the same happens when typing. The text is entered in the input, though, and the soft keyboard/focus on the input is not lost.
My project can be found over here: http://www.gortzfruit.nl/new/
The problem is that I have been searching for a solution for a while now, and found similar issues of which the solutions were not working out for me. Some topics -and solutions- I have been looking into were:
https://github.com/scottjehl/Device-Bugs/issues/3
-Here it is suggested that the problem lies within positioned elements. Especially absolute within fixed positioned elements. This is recurring in my design, but once removed it did not solve the problem.
Android Browser textarea scrolls all over the place, is unusable
-This one suggests that the problem is with the css-properties -webkit-transform: translate3d(0, 0, 0); and -webkit-backface-visibility: hidden;. I did not include these by myself, but I thought a Google Maps API I included might use these. I found that they don't use it either, after analyzing the markup Google Maps API produces.
How can I prevent wild scrolling when a fixed position text input form field gains focus? -This one is focused on trying to cope with the problem. Setting the body to overflow:hidden; was suggested to block scrolling while being focused, but it did not work for me.
disable scrolling on input focus in javascript
-Here it is suggested that returning false on keydown might solve the problem, which I tried with no success. This one block my text from being actually entered in the input.
I know this is related to the bug in Android which causes this weird scrolling. But I don't know anymore how to cope with this. For me it does not matter whether I find out how to avoid the bug or whether I find a hack to make the bug unnoticable. I just want to get rid of the weird scrolling behavior while typing and focussing/blurring on textboxes.
Thanks in advance,
Jeroen
Remove the meta viewport tag from your markup and add this immediately after the opening body tag:
<script type="text/javascript">
<!--
(function() {
var meta = document.createElement("meta");
meta.setAttribute('name','viewport');
var content = 'initial-scale=';
content += 1 / window.devicePixelRatio;
content += ',user-scalable=no';
meta.setAttribute('content', content);
document.getElementsByTagName('head')[0].appendChild(meta);
})();
//-->
</script>
This will give you the best experience on mobile (amazing image rendering too!). I noticed on my device (which isn't Android) I had some weird scrolling/zooming issues and this eliminates that. Let me know if it works :)

How do I fix Html.fromHtml link focus visibility problems (in ICS and Honeycomb)?

To get a TextView to display (and act friendly with) Html strings my code looks something like:
// itemHtml is a String of HTML defined above
TextView itemContent = (TextView) findViewById(R.id.itemContent);
itemContent.setText(Html.fromHtml(itemHtml));
itemContent.setMovementMethod(LinkMovementMethod.getInstance());
If the Html string has a link, TextView results in links that are clickable and focusable. When the user focuses on a specific link (e.g. by using the d-pad), the link text changes in some significant way to show that focus was obtained.
The problem is that when I test this same pattern using devices with a d-pad using Honeycomb (e.g. a Google TV) or Ice Cream Sandwich flavors of Android, the link in the text shows no noticeable indication that the link has focus.
I know it is getting focus, because when you then hit enter it does the specified action. You can even move around between various links in the text; you're just left guessing which link you're currently at, which results in a very bad user experience.
Is there something I'm doing wrong? Is there some way to fix this or work around this?
Edit: After going a bit nuts, I finally thought I found a solution. However, this solution only works for Honeycomb. ICS is still not solved!
As of API 11, Android has a new setting on TextViews for defining whether the text is selectable.
You can set it using setTextIsSelectable(true) on a TextView, or define it in the XML layout android:textIsSelectable="true"
It's probably best to define it in XML, so that keeping the app backwards-compatible is trivial. Just make sure you're targeting version >= 11, or you'll probably get an error.
The way HTML.fromHTML operates is by creating "spans" with varying effects throughout the various characters of the string. One workaround for this would be to use ClickableSpan coupled with another of the CharacterStyles to colorize the text as clickable. The previous span will allow you to register a callback, and this callback could be to broadcast an intent to view a url (which would open a browser).
The text colour state lists for Honeycomb+ might not set the focused state to a different colour, or you override the colour to be constant.
Check the colors + styles in your_android_sdk_directory/android-14/data/res/
Setting the text to android:autoLink="web" might also help?
The best way to do that is to add CSS styling to your html. I know Android supports :hover selector. So you might right something like this:
String myLink = "your link"
Html.fromHtml(myLink);
and find a way to include CSS data to it: (I'm not sure how but I think it's possible)
a :hover {
color: red;
}
UPDATE:
I think the answer of your question is there.

How tot scroll to end of an android TextView?

I have a android.widget.EditText (in multi line read only mode) in which I display some informations (the left half):
From time to time additional informations are added to the end of this android.widget.EditText and then I would like to scroll to the end of the the field (perhaps only scrolling to the end if already positions at the end which I think is even more user friendly).
Surprisingly I was unable to find any information on cursor and scroll movement in android.widget.EditText.
I found this posting but i don't have a ScrollView and I wonder why would I want one as a android.widget.EditText can handle it own scolling.
Any ideas or insights? What did I miss?
If scrolling to the end is all you want then the following will do:
this.Printout.setText ("");
this.Printout.append (Service.Get_FP10_Printout ());
The trick here: android.widget.EditText.append will scroll to the end of the field for you. So I delete the text and then append what I want to display.
If you need any other scrolling then you need to envelop the android.widget.TextView with an android.widget.ScollView (as lumis suggested) and use the trick from Patrick.
You know, Casio FX602P was my very first programmable computer!
I am not sure if editView can be made to scroll on its own, but if you envelop a textView with a scrollView and disable the scroll bars you should get what you need.
One other possibility came to my mind; if you use a List instead that would allow not just to scroll but to select the line of code which one wants to edit in the display on the right...
To accomplish this you must wrap the EditText in a ScrollView and control it through it's parent. It was previously possible to simply use EditText.append to accomplish this as indicated by one of the answers append here. However google has made all standard EditText's AppCompat now which has changed the behavior of the append function, it no longer scrolls to the end.
I found out the hard way as my app's functionality changed after a compile with the newer API.

Navigating Textviews using arrow keys

My application has a simple 'About' box.
It has a few clickable TextViews (email addresses, phone nos, addresses) all contained within a relative layout within a ScrollView (To accommodate low res screens).
The device I am testing with (Motorola Charm O.S ver 2.1 update 1) has a regular QWERTY keyboard. The problem I am facing is with the use of the arrow keys.
I want the cursor to move predictably from one clickable field to the next and this is where I need help. On the fields that don't need focus I have set the android:cursorVisible="false".I tried using the android:nextFocus* properties but still don't get the desired behavior.
The cursor gets stuck in the first field and overall the behavior is a bit unpredictable. Any ideas on how to get this done. Right now trapping the keys using code seems to be the only option.
TextView.setMovementMethod(LinkMovementMethod.getInstance())
The documentation is a little terse but it's basically what you are looking for.

Categories

Resources