Bottom Sheet doesn't EXPAND or COLLAPSE
I have made a very basic Bottom Sheet for my sample project to do a flowing page. 1st I made the layout : <?xml version="1.0" encoding="utf-8"?> 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:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/mainContent" android:fitsSystemWindows="true" tools:context=".MainActivity"> android:layout_height="match_parent"> android:layout_height="match_parent" android:orientation="vertical" android:paddingTop="24dp"> <Button android:id="@+id/btn_1" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Button 1" android:padding="16dp" android:layout_margin="8dp" android:textColor="@android:color/white" android:background="@android:color/holo_green_dark"/> android:id="@+id/bottom_sheet" android:layout_width="match_parent" android:layout_height="350dp" android:clipToPadding="true" android:background="@android:color/holo_orange_light" app:layout_behavior="android.support.design.widget.BottomSheetBehavior"> android:layout_height="match_parent" android:text="Bottom Sheets" android:paddingTop="16dp" android:textSize="16sp"> In MainActivity i've written these codes: public class MainActivity extends AppCompatActivity implements View.OnClickListener { private BottomSheetBehavior mBottomSheetBehavior; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); View bottomSheet = findViewById(R.id.bottom_sheet); Button btn1 = findViewById(R.id.btn_1); btn1.setOnClickListener(this); mBottomSheetBehavior = BottomSheetBehavior.from(bottomSheet); mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); } @Override public void onClick(View view) { switch (view.getId()) { case R.id.btn_1: mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); break; } } } But when i run the app on the emulator the BottomSheetBehavior is EXPANDED! When i changed the code to this: switch (view.getId()) { case R.id.btn_1: mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); break; And press btn_1 BottomSheetBehavior does not collapse, what is the issue? This is my gradle: dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'com.android.support:appcompat-v7:28.0.0-alpha3' implementation 'com.android.support.constraint:constraint-layout:1.0.2' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' implementation 'com.android.support:design:28.0.0-alpha3' }
1
# Users who requested the code (so far)
$10
Suggested price from buyers at which they’d buy
Potential revenues from requesters (actual revenues can be significantly higher)
Time of last request:on Jun 25, 2018
Tags:android
If you own such codes, please set up an offer and then invite users to it by clicking on «Invite to offer».
If you’re also be willing to buy those codes then click on «I’d also buy it» (no commitment to buy, but please only click when you’re serious about it).
Tell people about Sellcodes and get 20-40% on every resulting sale!