i have botton inner of BottomSheetDialogFragment, i want botton always stay in bottom of screen when bottomSheet slide up / or drag, button not appear only when BottomSheet dismiss, this is layout of bottomSheetDialog
<FrameLayout>
<!--content-->
<LinearLayout
<!--header-->
<LinearLayout>
</LinearLayout>
<RelativeLayout>
<!--BOTTON-->
<Botton/>
</RelativeLayout>
</FrameLayout>
but button always in bottom of layout bottomSheet, not in bottom of screen.
how to keep it under the screen
i want create like comment line, but ui comment is button and i'm using buttonSheetDialog
Related
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>
I am working with bottom sheet and it is working great if I dont add margin top.
I want the bottom sheet to fill the screen when pulled up but it also goes behind the Action Bar.
To solve this, I added margin top to the bottom sheet equivalent to the height of action bar, it works great until bottom bar is back to bottom.
<RelativeLayout
android:id="#+id/rl_bottom_sheet"
android:layout_width="match_parent"
android:layout_height="280dp"
android:margin_top="60dp"
app:behavior_peekHeight="80dp"
app:behavior_hideable="false"
app:layout_behavior="#string/bottom_sheet_behavior"
android:background="#drawable/ic_camera">
When bottom sheet is slided down, margin is no more there and view above the screen becomes equal to peekHeight + marginTop
Before Expanded
Collapsed after expanding once
One option is to use a Toolbar instead of adding a margin to the BottomSheet. You can put this inside the CoordinatorLayout at the top so it will be behind the BottomSheet. Make sure the View that has the BottomSheetBehavior is at the bottom of the layout and that it has a higher elevation than the Toolbar.
I can suggest you to change the root layout - from CoordinatorLayout to any other (Relative/Linear and so on). And after that you can add your CoordinatorLayout in your new root ViewGroup with desired marginTop.
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="80dp"
I have a bottom sheet with its height and width set to match_parent. So when on button click I set the behavior to STATE_EXPANDED like this:
mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
My Bottomsheet is defined as below:
<FrameLayout
android:id="#+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:elevation="#dimen/design_appbar_elevation"
app:behavior_hideable="true"
app:layout_behavior="#string/bottom_sheet_behavior">
<include
android:id="#+id/bottom_sheet_content"
layout="#layout/bottomsheet_layout" />
</FrameLayout>
I am monitoring states with the BottomSheet Callbacks.
I click on a button and bottom sheet expanded to full screen.
Its current State is STATE_EXPANDED
I quickly swipe down on the bottom sheet. (Not fully drag till it closed, simple swipe down like scrolling)
It stops at the middle and its state is logged as STATE_COLLAPSED
If I swipe again it is all gone and its state is STATE_HIDDEN
I don't understand why it stops in the middle. How can I make it hidden with a single swipe.
I tried that by setting peek_height to 0dp. By this, it never encounters the STATE_HIDDEN. When hidden, its state becomes STATE_COLLAPSED. I just don't understand this states.
How to achieve STATE_HIDDEN with a single swipe down?
Kinda late but I just stumbled upon this while searching for something similar.
This is how you can skip the collapsed state:
In XML by adding app:behavior_skipCollapsed="true" to the BottomSheet view.
OR
Programmatically with setSkipCollapsed(boolean).
Good day (or evening, or night)
I'm developing an app for android and I'm very curious about one thing. I have an activity, where user chats with another, like "im" chat. There are an EditText on the bottom and some kind of actionbar on the top. What I need is when user enters a message and the software keyboard is on screen, my activity should move up, but the actionbar should still be "glued" to the top of the screen, because it has some valuable controls on it.
Again, that's not an ActionBar, but just a 48dp height layout in a parent vertical linear layout. So I need to know is there an easy way to prevent it from moving to the top, when the layout moves off the screen.
I tried to put everything in a FrameLayout and put this bar on top of it, but on keyboard opens it goes off the screen too...
On you Activity at AndroidManifest you should put this: android:windowSoftInputMode="adjustResize"
Use something like this:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.myapp.MyActionBar
android:layout_width="match_parent"
android:layout_height="48dp"/>
<LinearLayout
android:id="#+id/mylayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1dp"/>
<!-- Add your edittext and button -->
</LinearLayout>
This will make sure the actionbar and edittext + button are allways on screen, and the mylayout takes up the rest of the screen. When your keyboard is shown, the mylayout will shrink.
Try adding android:windowSoftInputMode="adjustResize" to your activity in the manifest. This tells Android to completely resize your layout when the keyboard comes up, rather than pan it. Note that if there isn't enough room for the entire layout this still won't work. But you ought to be able to make it work if your top level layout is a RelativeLayout, with the edit text set to align bottom, the top bar to align top, and the middle section to fill_parent and be above the edit text and below the bar.
use a RelativeLayout as your base Layout and add android:layout_alignParentTop="true" to your action bar to keep it up
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="#+id/action_bar_layout"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentTop="true" >
</LinearLayout>
<TextView
android:id="#+id/text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>