adjustPan ScrollView above included layout - android

Hey there I'm dealing with some kind of problem showing the softkeyboard in some android layout the layout ist organized like this:
<RelativeLayout>
<ScrollView>
Some stuff here...
</ScrollView>
<include ... />
<RelativeLayout>
I habe already set adjustPan and I have tried some experimental stuff with focusing. But my content inside the ScrollView is getting hidden by the included layout everytime its getting focus.
It may be just a logical problem but how do I tell e.g.: my EditText which is in the center of some other stuff like TextViews, ViewPager etc. to be above the included layout when gaining focus ?

Related

Recyclerview items invisible/ Missing when keyboard is visible

Problem :
My recyclerview item have one edittext.
If user edit the edittext -> Keyboard will appear & some list items missing. (means recyclerview shrink when keyboard open after keyboard close shrinked recyclerview not expanded)
My xml design
<ScrollView>
<ConstraintLayout>
<other views>
<recyclerview/>
</ConstraintLayout>
</ScrollView>
Manifest activity windowSoftInputMode
android:windowSoftInputMode="adjustPan"
Tried lot of google & SO. But no luck. Anyone give me solution. If anyone need more info let me know. I will give more details.
UPDATE:
My xml code - https://pastebin.com/diz4t9mp
My issue - Video reference
https://drive.google.com/file/d/15J4hOnCM7Gu6uvklhzlSSD7XUCmmGmzg/view?usp=sharing
Change this
<ScrollView>
<ConstraintLayout>
<other views>
<recyclerview/>
</ConstraintLayout>
</ScrollView>
to
<android.support.v4.widget.NestedScrollView>
<ConstraintLayout>
<other views>
<recyclerview/>
</ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
NestedScrollView is used when there is a need for a scrolling view
inside another scrolling view. Normally this would be difficult to
accomplish since the system would be unable to decide which view to
scroll , it supports acting as both a nested scrolling parent and child on both new and old versions of Android.

Cant click items inside CollapsingToolbarLayout

I've implemented the CollapsingToolbarLayout that looks like this:
It collapses when I scroll, however there's a big problem: I am unable to click items inside it (back button, edit button, edit text field etc). None of the items react to click/touch events.
Now, the "logic" sits in XML with the following structure:
<CoordinatorLayout>
<AppBarLayout>
<CollapsingToolbarLayout>
<RelativeLayout/> here's where the panel layout sits
<Toolbar/>
<NestedScrollView/>
//close tags as appropriate here
How do I make the items clickable (well, not by setting android:clickable="true" for sure)? Is it possible without writing listeners in Java/Kotlin code?
Try to add this XML attribute
android:descendantFocusability="blocksDescendants"
to your CollapsingToolbarLayout

Android: Switch loses focus after click

Hey Hey currently I am developing an application that contains a form, with some edittext fields, some checkboxes and a switch at the end. The layout looks like this:
<RelativeLayout>
<ScrollView>
<LinearLayout>
<LinearLayout>
<TextView></TextView>
<Checkbox></Checkbox>
</LinearLayout>
<LineraLayout>
<TextView></TextView>
<EditText></EditText>
</LinearLayout>
<LinearLayout>
<TextView></TextView>
<Switch></Switch>
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
So now, if I click the switch, the switch looses its focus and the scrollview scrolls to the first form element, the checkbox. I already tried to use the descendantFocusability attribute with "blocksDescendants" in the upper LinearLayout of the Switch, but it doesn't work.
Anyone got an idea how to solve this issue?
Okay, I was able to fix the problem by myself. I'm posting my solution, so that it could be helpful for other people who might have the same problem.
In my code there was a specific function, which calls the setVisibility(View.Visible) method for all my form elements (this is used in my project to display possible dependend form elements, that should only show up, when the user clicks on a checkbox or sth else).
If I click on the switch or a checkbox my code calls the setVisibility-Method for all the form elements, also for the Edittext. This requests the focus and so the scrollview scroll this element to the middle/focus of the screen.
I solved the problem by not calling the setVisibility method for objects, that are already visible.
Hopefully this could be helpful for someone else ;-)

Keyboard overlaps on EditText, when I'm dynamically add view

I'm dynamically adding views (RelativeLayout with EditText) into FrameLayout and setting their positions using setTranslate methods. But on screen keyboard overlaps on my EditText.
I've tried to set
android:windowSoftInputMode="stateHidden|adjustResize|adjustPan"
in manifest, but there is still no result. I'm using 11 SDK.
How to solve that problem?
Here is screeshots:
As you have already tried activity android:windowSoftInputMode in your Manifest. You can do it by chaging the Layout to relative and make your EditText android:layout_alignParentBottom="true"
Refer this Example
Surround your Relative layout with a <ScrollView>.
Place your view inside of this. ScrollView only accepts one child though, so you may need to add all of your components to a LinearLayout, then add the LinearLayout inside of the ScrollView.
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</ScrollView>
If that's not what you're looking for then add
android:layout_alignParentBottom="true"
The only thing that worked for me was putting an update in the manifest file within that specific activity tag which is hosting the fragment whose layout is creating the issue in scrolling. The solution is given by:
android:windowSoftInputMode="stateVisible|adjustPan"

ScrollView not displaying some UI elements

I'm developing an application with executes searches via an API on a web server. My search page displays well in portait mode but is too big for landscape mode so I've decided to simply contain all UI elements in a ScrollView by customising the XML in layout-land folder. The problem is, the buttons on the bottom of my form are not being shown in landscape ScrollView. I don't use ScrollView in portrait so maybe that's the problem? The layout XML is like this:
<LinearLayout>
<ScrollView>
<LinearLayout>
<TableLayout>
<!-- stuff here is being shown (table with TextViews and EditTexts -->
</TableLayout>
<LinearLayout>
<!-- stuff here is not being shown (3 Buttons) -->
</LinearLayout>
</LinearLayout>
</ScrollView>
Most likely you forgot to set android:orientation="vertical" to your LinearLayout (direct child of ScrollView).

Categories

Resources