Chciałbym wyświetlić okno dialogowe dolnego arkusza o mniejszej szerokości niż szerokość ekranu.BottomSheetDialog z przezroczystym tłem
Na przykład opcja na akcje z Muzyki Google Play na Nexusie 9.
Czy wiesz jak to osiągnąć?
Na razie udało mi się zmniejszyć szerokość zawartości arkusza, ale tło nadal ma szerokość ekranu i wyświetla białe tło.
Niektóre kodu:
build.gradle
compile 'com.android.support:design:23.3.0'
główną działalność
@Override
protected void onCreate(Bundle savedInstanceState) {
...
mBottomSheetDialog = new BottomSheetDialog(this);
mBottomSheetDialog.setContentView(R.layout.sheet_test);
mBottomSheetDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
mBottomSheetDialog = null;
}
});
mBottomSheetDialog.show();
}
sheet_test
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="100dp"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
style="@style/TextAppearance.AppCompat.Body1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Some Text"
android:textColor="@color/colorPrimary" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#ddd" />
<TextView
style="@style/TextAppearance.AppCompat.Body1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dp"
android:text="Some Text" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#ddd" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
proszę podzielić się kod :) –
Jaka wersja Biblioteki projektu jesteś za pomocą? Czy próbowałeś tego z najnowszym (23.3.0)? – ianhanniballake
Myślę, że po prostu trzeba uczynić aktywność nadrzędną przejrzystą. Zobacz http://stackoverflow.com/questions/2176922/how-to-create-transparent-activity-in-android – Madushan