Monday, September 6, 2010

[android-developers] Re: How does Android determine whether to move the layout up when showing the softkeyboard?

Hi Ed,

On Sep 7, 6:25 am, Ed <edscha...@gmail.com> wrote:
> Instead of View.INVISIBLE try View.GONE.

Sorry, you misunderstood. View.INVISIBLE was just for testing purposes
to see if it makes any differences. In my app I cannot hide the
elements of course, I need them there to be visible to the user.
I just wanted to point out that by setting View.INVISIBLE to the
listView, the behaviour I want (the layout to stay fix) can be
achieved, but I am wondering *why* ? What's the logic behind it?

(So both View.INVISIBLE and View.GONE already have the same desired
effect; but I *do* want to show the element to the user of course.)


> http://developer.android.com/reference/android/view/View.html
>
> Also in your scroll view layout try setting
> android:fillViewport="true" on the scroll view.


The scroll view works fine, with the scrollView, the layout remains
fix (what I want); I want the layout that uses the *ListView* to stay
fixed as well when I press the search button.

I also already tried to set android:isScrollContainer="false" to the
list view, but it makes no difference either. (ListView doesn't have a
fillViewport attribute)

Mathias

>
> Ed
>
> On Sep 7, 12:03 am, Mathias Lin <m...@mathiaslin.com> wrote:
>
>
>
> > Interestingly though: when I set my ListView visibility to
> > View.INVISIBLE in my first activity, then the layout doesn not get
> > moved up anymore!
>
> > This is my layout/xml:
>
> > 1)http://pastebin.com/5zzVxjbK
> > ListView where layouts is been moved up by the softkeyboard
>
> > 2)http://pastebin.com/KFtPuHvP
> > ScrollView/LinearLayout, where layout remains fix by the softkeyboard
>
> > On Sep 6, 8:48 pm, Mathias Lin <m...@mathiaslin.com> wrote:
>
> > > How does Android determine whether to move the layout up when showing
> > > the softkeyboard?
>
> > > Note: I am aware that the activity property
> > > android:windowSoftInputMode="adjustResize|adjustResize|
> > > adjustUnspecified" exists, as described herehttp://developer.android.com/guide/topics/manifest/activity-element.h...
> > > , but in my case it doesn't seem to have any effect. This is my
> > > problem:
>
> > > I have two activities, pretty much the same layout, but the first one
> > > is using a ListView that holds a list of buttons. The second activity
> > > holds a scrollview with buttons. The rest is the same, same number of
> > > buttons, same height of elements, etc. (All elements fit on the
> > > screen, so actually the user doesn't need to scroll in the scrollview
> > > or listview.)
> > > Please see my screenshot to get an idea:http://i.imgur.com/UNXPz.png
>
> > > Now, when I press the search button to open the search input bar, in
> > > my first activity, the entire layouts gets moved up. While on the
> > > second activity, the layout is not being moved up but the softkeyboard
> > > just displays on top of it. This is actually how I want it to behave.
> > > How can I achieve the same with my activity that's using the ListView?
>
> > > In my manifest, initially I didn't specify any
> > > android:windowSoftInputMode attribute, but even if I do, it doesn't
> > > make any difference; I tried all three values (adjustPan,
> > > adjustResize, adjustUndefined, without any difference).
>
> > > This is my layout:http://i.imgur.com/UNXPz.png
>
> > > (I'm not posting any code here for now, I'm more interested generally
> > > how it's been exactly determined whether Android moves the layout up
> > > or just displays they softkeyboard right on top of the existing layout
> > > without moving it.)
>
> > > I couldn't find a specific logic that's been followed. When I reduce
> > > the number of buttons, when I even wrap the listView in a ScrollView
> > > (just for the sake of trying to see what's happening), the layout just
> > > won't stay fix.
> > > On the other hand then, I have activities in my app that contain only
> > > one large ListView, and on that one the layout also remains fixed.
> > > First I thought it's related to ListViews, but it seems not to.
>
> > > btw: nowhere in my manifest am I explicitly specifying the
> > > windowSoftInputMode attribute.

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment