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
Related
So we have a 3 part app structure with 2 toolbars: 1 that is significant and should be always visible and 1 that is insignificant and should only be visible when user has scrolled to the top of page .the third part is a complex structure with nested view group, swipe to refresh, recycler view and some extra views . Note that we are not using the Collapsible toolbar or any other toolbar, but rather custom viewgroups.
I tried to achieve the behavior of toolbars with my current xml structure like this (notice the layout behavior flags) (PS: i cannot share the exact code,but would provide more details if needed)
<Coordinator layout>
<include layout=“xyz”> <— <appbarlayout>
<linearlayout :layout_behavior:scroll|enterAlways …/>
<linearlayout :layout_behavior:noscroll …/>
</appbarlayout>
<swipe refresh layout : layout_behavior="....AppBarLayout$ScrollingViewBehavior”>
<Nested ScrollView : mp/mp , fillviewport :true>
<constraint layout : mp/mp>
<RecyclerView : nested scrollin enabled:false (via java code)>
<View>
</constraint layout>
</nested scrollview>
</swipe refresh layout>,
</Coordinator layout>
<!-- mp = match_parent -->
the result looks something like this( gif / video ) (note the gif/video has some delay, please wait 7-8 seconds to see the action ) .
As you can see, the upper toolbar gets hidden when scrolled very hardly, but when scrolled slowly, the upper bar does not hide.
What can i do to fix this? i have tried changing the behavior flags as well as setting the heights as wrap content. I am guessing it is either due to wrong flags or due to complexity in bottom layout
My layout looks something like this
<LinearLayout>
<Toolbar/>
<Scrollview>
<More views including a edittext in the bottom/>
</Scrollview>
</LinearLayout>
The problem is that whenever I select the editext to type something the softkey pushes the edittext up, which is how it's supposed to work but the entire layout is pushed up along with it.. I want to keep the toolbar on the screen, just like how it is in WhatsApp where the toolbar remains on the screen when the edittext is pushed up and down by the softkey.
just set
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:isScrollContainer="false">
and also add this in your linearlayout
android:windowSoftInputMode="adjustPan"
I am looking into CoordinatorLayout and ConstraintLayout and I want to know if it's possible to achieve something as in :
As you can see my layout, has:
the toolbar which is not affected by this. The toolbar is on the main activity and it's not changed.
under the toolbar there is a fragment loaded with its layout. The layout contains a ImageView at the top, some EditTexts and a RecyclerView
Behavior:
When user taps on the red EditText I want the layout to scroll up, so that the focused EditText is at the top of the screen with the RecyclerView under it.
At any time the user can scroll down and the initial layout gets shown.
My question is: what would be the best way to create this animation and behavior?
I managed to obtain the desired behavior by using in the layout:
<CoordinatorLayout>
<AppBarLayout>
<CollapsingToolbarLayout
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
<My layout that will get scrolled to the top and be hidden>
</CollapsingToolbarLayout>
<RedEditText which will scroll up until the CollapsingToolbar is collapsed>
</AppBarLayout>
<RecyclerView/>
</CoordinatorLayout>
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 ?
I have created custom tab bars by following the post given below:
How to create a Tab-like UI in Android?
No I need to display a set on sub menu when the center tab (actually it is a button) is clicked. I need the sub menu to pop up like in this drawing (sub menu should be above my main layout):
I believe that this can be achieved by putting an additional layout above the custom tab bar in which a set of buttons can be placed one after another. But I am not sure which layout needs to be used and how I can get the same style in the drawing. Please help me to find a solution.
you're correct with just adding another layout above the button you want to open it, and then setting its visibility to gone until you want to animate in it.
a regular LinearLayout would work fine, and then adding 4 buttons to it would work as well, then you would want to make sure those buttons used the same styles as the built-in android menu buttons (or style it yourself) but check out some of the built in styles here
example:
your activity
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
//all your other activity layout stuff goes here
<!--add your new menu-->
<LinearLayout
android:id="#+id/my_menu_layout"
android:visibility="gone"
... />
<Button
android:id="#+id/menu_btn_1"
style="#android:style/Widget.Holo.ActionButton.TextButton" //as example of built-in style
... />
//more buttons
</LinearLayout>
then in your activity class, assign an onClickListener to the button that will toggle the menu and animate the view in
//animation xml you make
Animation inFromBottom = AnimationUtils.loadAnimation(this, R.anim.layout_in_bottom);
mMenuLayout.startAnimation(inFromBottom);
mMenuLayout.setVisibility(View.VISIBLE);
now your view will animate in and you can go about adding onClick listeners to the buttons