I have a RelativeLayout which has a nested empty FrameLayout and a ListView below the FrameLayout. I am adding a view to the FrameLayout with animation (setting android:animateLayoutChanges="true" in xml) and I am doing this because I want it to appear at the top of my window. So it appears with the default fade in animation. The ListView on the other hand moves down, but it is not animated. What can I do for the ListView to slide down to its position, because this is not very good looking. If I have to change the way I define my views in the layout, that's ok also. I will consider every suggestion. Thx
Here is my code:
<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"
>
<FrameLayout
android:id="#+id/frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"></FrameLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/frame"
/>
</RelativeLayout>
Related
I have a main Relative layout within which there is a ListView and another Horizontal LinearLayout which I want to place at the bottom of the screen.
When the items in the list view fills up the screen, it gets hidden under the Horizontal Linear layout.
How do I restrict the ListView to take the space only till the Horozontal Linear layout and stop the content of the list view from hiding.
Thank you for your help and suggestions.
here is my Layout and a screen shot of how it looks.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_chat_window"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.raoburugula.speech_soft_ivr.ChatWindow">
<ListView
android:id="#+id/lvMessages"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#android:color/transparent"
android:dividerHeight="5dp"
/>
<LinearLayout
android:id="#+id/llAction"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:weightSum="5"
android:visibility="invisible">
<EditText
android:id="#+id/etMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="4"/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/btnSendMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/ic_send"
android:tint="#android:color/white"
android:onClick="sendMessage"
/>
</LinearLayout>
</RelativeLayout>
I would remove the android:visibility="invisible" line from the LinearLayout. and check how that works. I also one time built my layout from the bottom up to allow me to place 2 buttons at the bottom of the screen, in hindsight I probably didn't need to. I wasn't able to comment on your post so I made this an answer instead.
Also have you tried a normal button in place of the FAB(FloatingActionButton)? A FAB might have properties that make it visible and at the bottom right regardless of its parents attributes
You made the horizontal linearlayout align the bottom of parent ,yes;
and you must make your listView above the horizontal linearlayout.
I have an issue where i would like to fill the expanded space with a custom color or gradient in that matter. However RecyclerView works in a way that it expands the rows by leaving an empty space between items which results in seeing a white background (screenshot) or whatever is the background color. The empty space gets filled after the expansion animation, where onBindViewHolder gets called.
Could this be solved somehow, where I could fill this empty space with a custom view, so it gets epxanded nicely without color flickering?
Is there a way I could attach a listener to the animation and overlay it with a virtual view for that time?
Right before the child views are shown:
After the child views are shown (group is expanded)
EDIT: added RecyclerView's xml as requested
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
style="#style/myRecyclerViewStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</FrameLayout>
group_item.xml
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="#dimen/list_group_item_height"
android:background="#android:color/holo_green_light"
android:clickable="true"
android:foreground="?attr/selectableItemBackground">
<TextView
android:id="#android:id/text1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"/>
</FrameLayout>
child_item.xml
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="#dimen/list_item_height"
android:background="#android:color/holo_green_light"
android:clickable="true">
<TextView
android:id="#android:id/text1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"/>
</FrameLayout>
Even if i change all the heights to wrap_content its still the same, the animation just epxands the views and leaves an empty space (recyclerView's background), which i would like to fill somehow.
This is taken from this library: https://github.com/h6ah4i/android-advancedrecyclerview
This should be because you might have given match_parent in your adapter classes. Hope this is helpful :)
I think it can be achieved by NestedScrollingChild NestedScrollingParent.
But I can't really understand them.Who can help me out!
Product manager insists on the design.
The ScrollView contains a LinearLayout ,a "TabLayout" and a ViewPager.
The ViewPager contains 2 fragment contains RecyclerView or just only 2 RecyclerView.
When the ScrollView scroll to Bottom , the RecyclerView can scroll to Bottom.
When the RecyclerView scroll to Top , the ScrollView can scroll to Top.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="match_parent"
android:layout_height="1000dp" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="60dp"></TableLayout>
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"></android.support.v4.view.ViewPager>
</LinearLayout>
</ScrollView>
Just change your ScrollView to android.support.v4.widget.NestedScrollView
Post your xml if that doesn't work
ِYou can do that, but it's not good at all to use this type of layout
First you need add "wrap_content" abilty ViewPager and RecyclerView's
ViewPager and RecyclerView
Now you can use scrollview easily, put all item in it
If you want some effect or something when user scrolling or some item get visible in scrolling you can get position of item then make listener on
"OnScrollChangedListener" of scrollview
I have a ListView over a LinearLayout. There are clickable elements in the LinearLayout and since the ListView is transparent I can see those elements, and would like to be able to click on them, but even though the ListView looks transparent, it behaves as a barrier and doesn't let me click on the elements.
Is there a way I can click through the ListView?
If I change the ListView layout_height to wrap_content, it behaves as I want, but I need it to start with a certain height, so the items will stack at the bottom with android:stackFromBottom="true".
This is an example of how the code looks like:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
(Clickable elements)
</LinearLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/transparent"
android:transcriptMode="normal"
android:layout_marginTop="100dp"
android:layout_marginBottom="361dp"
android:stackFromBottom="true"
android:listSelector="#android:color/transparent"/>
</RelativeLayout>
Extend listview and override the onTouch() method and pass it down to the underlying views
I'm trying out an official example on LayoutTransition. I've modified it in order to have 2 containers. I add new items to 1'st (top) container with animation and the 2'nd (bottom) container moves down with slide animation, as expected.
But when I remove item from 1'st container, the whole 2'nd container goes beneath 1'st container, while 1'st container is shrinking height with animation (while animation is playing last element of 1'st and first element of 2'nd are intersecting).
Is there any way to make 2'nd container slide up while 1'st container is shrinking?
layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#ffffff">
<ScrollView android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout android:id="#+id/container1"
android:background="#drawable/border"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:showDividers="middle"
android:divider="?android:dividerHorizontal"
android:animateLayoutChanges="true"
android:paddingLeft="16dp"
android:paddingRight="16dp" />
</ScrollView>
<ScrollView
android:layout_width="match_parent" android:layout_height="wrap_content">
<LinearLayout android:id="#+id/container2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:showDividers="middle"
android:divider="?android:dividerHorizontal"
android:animateLayoutChanges="true"
android:paddingLeft="16dp"
android:paddingRight="16dp" />
</ScrollView>
</RelativeLayout>
This may not be the correct answer and it's definitely too late for this answer but it might be helpful and I had a similar issue where one item was disappearing and I wanted the second item to expand while the item was disappearing. I used setStartDelay() of LayoutTransition in code for both LayoutTransition.CHANGE_DISAPPEARING and LayoutTransition.DISAPPEARING to 0, as well as setDuration() of both to the same value. You might have to mess with those values for LayoutTransition.CHANGING, since that affects expanding views, but honestly LayoutTransition may not be capable of it (though I definitely don't know for sure), because while the expanding view is DEFINITELY CHANGING, the second item moving up is probably not CHANGE_DISAPPEARING, though you want a similar animation.
my code:
customTransition.setStartDelay(LayoutTransition.DISAPPEARING, 0);
customTransition.setStartDelay(LayoutTransition.CHANGE_DISAPPEARING, 0);
customTransition.setDuration(LayoutTransition.DISAPPEARING, hideArticleBar.getDuration());
customTransition.setDuration(LayoutTransition.CHANGE_DISAPPEARING, hideArticleBar.getDuration());