fedepaol / dragqueen

Sample app that shows android's ViewDragHelper usage
Apache License 2.0
101 stars 28 forks source link

Hidden Button is not hidden #7

Closed juanBalian35 closed 6 years ago

juanBalian35 commented 7 years ago

I copied the exact same code before starting to make changes, built it and it looks like this. The hidden button is at the front, and the queen button is at the back, still, I can drag where the queen button would be. But everything that is in the outerlayout is visible.

fedepaol commented 7 years ago

I just recompiled the project and it works as expected. The order you declare the elements in the layout matter (i.e. latter elements are on top of earlier ones). Are you sure that your layout is similar to the one in the example?

juanBalian35 commented 7 years ago

I do not know, I have got the exact same 3 files as you do. Any idea of whats happening?

fedepaol commented 7 years ago

Can you share your layout xml file?

juanBalian35 commented 7 years ago

`<com.example.juanchi.myapplication.OuterLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white" android:id="@+id/outer_layout">

<Button
   android:id="@+id/hidden_button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="64dip"
        android:text="Hidden button"/>

<LinearLayout
    android:id="@+id/main_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:clickable="true"
    android:background="@android:color/holo_blue_dark">
    <Button
        android:id="@+id/queen_button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="64dip"
        android:text="Queen"/>
</LinearLayout>

</com.example.juanchi.myapplication.OuterLayout>

`

tonytonyhung commented 7 years ago

The problem is in the MainActivty. I think you exten appCompat. Just change it to Activity, then it work well. But... how to fix this ? i really want to use appCompatActivity . sorry for my english

tonytonyhung commented 7 years ago

oh, i found how to fix this, just change in xml like this

<com.whiterabbit.dragqueen.OuterLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white" android:id="@+id/outer_layout">

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <Button
        android:id="@+id/hidden_button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="64dip"
        android:text="Hidden button"/>
</LinearLayout>

<LinearLayout
    android:id="@+id/main_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:clickable="true"
    android:background="@android:color/holo_blue_dark">
    <Button
        android:id="@+id/queen_button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="64dip"
        android:text="Queen"/>
</LinearLayout>

</com.whiterabbit.dragqueen.OuterLayout>

-----------> you see that, put on the button to linear and it work like a charm But it just a trick. I want to know another solution

juanBalian35 commented 6 years ago

Fixed it by adding android:elevation to the main layout, like this:

<com.example.juanchi.animation.OuterLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorPrimary"
    android:id="@+id/outer_layout">

    <RelativeLayout
        android:id="@+id/main_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:elevation="3dp"
        android:clickable="true"
        android:background="@android:color/holo_blue_dark"
        android:layout_below="@+id/textView"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true">
        <android.support.v7.widget.Toolbar
            android:id="@+id/queen_toolbar"
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:layout_alignParentTop="true"
            android:background="?attr/colorPrimary"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            />
        <android.support.design.widget.TabLayout
            android:id="@+id/tab_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            />
        <android.support.v4.view.ViewPager
            android:id="@+id/pager"
            android:layout_width="match_parent"
            android:layout_height="fill_parent"
            android:layout_below="@id/queen_toolbar"
            />
    </RelativeLayout>

</com.example.juanchi.animation.OuterLayout>