【问题标题】:Slidingdrawer Android with fill_parent option带有fill_parent选项的Slidingdrawer Android
【发布时间】:2013-10-14 12:46:54
【问题描述】:

我似乎无法按照我想要的方式拿到我的滑动抽屉。我希望它一直延伸到布局的顶部,这不是问题......问题是如果我删除透明度选项,它下面的布局将不再可见。 我希望抽屉几乎不透明(类似于#D000),但在关闭时不会影响其下方的图层。只能用 XML 完成吗? 在疯狂和绝望中,我也尝试过颠倒抽屉的顺序和桌子的布局,当然结果不出所料……

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

    <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="horizontal"
        android:padding="30dip"
        android:background="#fff"  >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginBottom="25dip"
            android:text="@string/main_menu_select"
            android:textColor="#000"
            android:textSize="@dimen/dimenLabel" />

        <CheckBox
            android:id="@+id/accommodation_cb"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/accommodation"
            android:textColor="#000" />

        <CheckBox
            android:id="@+id/food_and_beverage_cb"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/food_and_beverage"
            android:textColor="#000" />

        <CheckBox
            android:id="@+id/fun_cb"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/fun"
            android:textColor="#000" />

        <CheckBox
            android:id="@+id/transport_cb"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/transport" />

        <CheckBox
            android:id="@+id/other_cb"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/other" />

        <Button
            android:id="@+id/submit_button"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:onClick="checkListing"
            android:text="@string/submit_label" />
    </TableLayout>

    <SlidingDrawer
        android:id="@+id/SlidingDrawer"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentBottom="true"
        android:background="#D000"
        android:content="@+id/contentLayout"
        android:handle="@+id/slideButton"
        android:orientation="vertical"
        android:padding="10dip" >

        <Button
            android:id="@+id/slideButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="^" >
        </Button>

        <LinearLayout
            android:id="@+id/contentLayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:clickable="true"
            android:orientation="vertical"
            android:padding="10dip" >

            <Button
                android:id="@+id/Button01"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_margin="2dp"
                android:text="Button 1" >
            </Button>

            <Button
                android:id="@+id/Button02"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_margin="2dp"
                android:text="Button 2" >
            </Button>

            <Button
                android:id="@+id/Button03"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_margin="2dp"
                android:text="Button 3" >
            </Button>
        </LinearLayout>
    </SlidingDrawer>

</RelativeLayout>

我的主要课程是膨胀此布局的默认视图。 谢谢

【问题讨论】:

    标签: android android-layout slidingdrawer


    【解决方案1】:

    您当前的工作假设颜色由单个字节表示。但事实并非如此。每种颜色由每种颜色的两个字节表示。因此,例如,如果您尝试使用#fff 提供颜色,那么它的完全不透明版本实际上将是不带alpha 的#FFFFFF 或带alpha 的#FFFFFFFF

    您应该从那开始,然后重新测试您的不透明度并更新您的问题。如果你得到一个透明的抽屉,那么它不应该影响它背后的数据,所以我不清楚你的要求是什么。

    【讨论】:

    • 这是一回事......或者至少它给出了相同的输出。我的问题是,如果抽屉不是完全透明的,它会影响其下方布局的颜色。因此,在此示例中,如果没有抽屉,我的复选框将是纯黑底白字,但是,使用不透明抽屉时,带有复选框的整个布局将获得半透明覆盖或完全不透明覆盖,具体取决于我提供的抽屉的 alpha 跨度>
    • 您是说抽屉关闭时会影响您原始布局的视图?就因为抽屉存在?那会很奇怪。
    • 正是……它可以是模拟器的东西吗?我会发布一个 scrnsht,但以目前的声誉我还不能上传图片
    • 老实说,我真的更熟悉使用 android.support.v4.widget.DrawerLayout 类而不是 SlidingDrawer 类,但不确定它为什么会这样做。听起来好像那里的抽屉可能由于某种原因没有完全关闭。
    • 似乎抽屉布局占据了我在 layout_height 选项中给它的空间。所以如果我把高度说 150dip,它会在关闭时占据屏幕的三分之一,就像它“节省”应该打开抽屉的空间一样......该死,无论如何谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-14
    相关资源
    最近更新 更多