我无法理解为什么ID为“透明”的ConstaintLayout
仍为白色。
我也试过使用android:background =“#00ffffff”,在SlidingPanel
(id right_side)的右侧透明。
我想在标准计算器应用程序中这样做。
<android.support.constraint.ConstraintLayout
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"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.constraint.ConstraintLayout
android:id="@+id/digits_area"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@id/buttons"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_weight="1.5"/>
<android.support.constraint.ConstraintLayout
android:id="@+id/buttons"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/digits_area"
app:layout_constraintVertical_weight="3">
<android.support.v4.widget.SlidingPaneLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sliding_pane_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.ConstraintLayout
android:id="@+id/digits"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
app:layout_constraintEnd_toStartOf="@id/operations"
app:layout_constraintHorizontal_weight="3"
app:layout_constraintStart_toStartOf="parent">
</android.support.constraint.ConstraintLayout>
<android.support.constraint.ConstraintLayout
android:id="@+id/operations"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="@color/colorAccent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintStart_toEndOf="@id/digits">
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--This part I want to make transparent-->
<android.support.constraint.ConstraintLayout
android:id="@+id/transparent_layout"
android:layout_width="0dp"
android:layout_height="match_parent"
app:layout_constraintEnd_toStartOf="@id/content"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintStart_toStartOf="parent" />
<android.support.constraint.ConstraintLayout
android:id="@+id/content"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="@color/secondaryLightColor"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_weight="4"
app:layout_constraintStart_toEndOf="@id/transparent_layout">
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.SlidingPaneLayout>
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
答案 0 :(得分:0)
尝试将主屏幕内容和SlidingPaneLayout放入FrameLayout中。
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<TextView android:layout_width="match_parent" android:layout_height="match_parent"
android:text="here goes the bottom non sliding main screen content. it takes the whole screen"
android:background="@color/colorPrimaryDark" android:textColor="@color/colorPrimary"
android:textSize="24sp" />
<!-- SlidingPaneLayout should be transparent - do not set background color -->
<android.support.v4.widget.SlidingPaneLayout
android:id="@+id/SlidingPanel"
android:layout_width="match_parent" android:layout_height="match_parent" >
<!-- first view takes whole screen is empty transparent placeholder -->
<View android:layout_width="match_parent" android:layout_height="match_parent" />
<!-- this is the paned that will slide - no background color too -->
<LinearLayout android:id="@+id/slidePane" android:orientation="horizontal"
android:layout_width="match_parent" android:layout_height="match_parent"
android:layout_gravity="right" android:layout_marginLeft="50dp" >
<TextView android:layout_marginLeft="16dp" android:background="#101010"
android:layout_marginTop="20dp" android:layout_marginBottom="20dp"
android:layout_width="wrap_content" android:layout_height="match_parent"
android:gravity="center" android:text="HI" android:textColor="@color/colorPrimary" />
<Button android:id="@+id/button" android:text="TEST"
android:layout_marginTop="10dp" android:layout_marginBottom="10dp"
android:layout_width="match_parent" android:layout_height="match_parent" />
</LinearLayout>
</android.support.v4.widget.SlidingPaneLayout></FrameLayout>