3
Googleサポートライブラリを使用してボトムシートを作成しようとしています。拡張状態のときにサポートボトムシートを非表示にできない
- だけ
- その高さが自動的に
- 計算され
これまでのところは良い、シンプルなものXMLで静的に定義され、プログラムで非表示にすることができます:目標は、シートを持つことです。この有望なisHideable()
もデフォルトでfalseになります。
しかし、シートがSTATE_EXPANDED
に設定されていると、ボトムシートはisHideable
を無視しているように見えます(画面全体をカバーするわけではありません)。それを不可解にする唯一の方法は、(私が欲しくない)ピークの高さを設定することです。
Activity.java
:それは拡大し、手動で高さを設定することなく、hideableない持つ方法(レイアウト変更を介して、またはトリガ)ここでを使用(スーパースリム)コードが存在しているあります
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
View bottomSheet = findViewById(R.id.bottomsheet);
BottomSheetBehavior behavior = BottomSheetBehavior.from(bottomSheet);
behavior.setHideable(false);
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:id="@+id/bottomsheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:behavior_hideable="false"
app:layout_behavior="@string/bottom_sheet_behavior"
android:background="@android:color/white">
<TextView
android:layout_width="match_parent"
android:layout_height="300dp"
android:text=":) :) :)"/>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
行動