0

I have the following layout structure:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    android:id="@+id/wrapper_layout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorPrimary"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.phoenetoaster.doitcalendar.MainActivity">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@color/white"
        android:orientation="vertical">
        </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/white"
        android:orientation="vertical">

        <EditText
            android:id="@+id/editText"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:layout_marginTop="105dp"
            android:hint="@string/event_name"/>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                style="@style/textviews"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/when"/>

            <TextView
                android:id="@+id/value_when"
                style="@style/textviewsChangingText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/today"/>
        </RelativeLayout>

        <!--Seekbar 2 -->
        <SeekBar
            android:id="@+id/seekBar_when"
            style="@style/seekbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>


        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                style="@style/textviews"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/time"/>

            <TextView
                android:id="@+id/value_time"
                style="@style/textviewsChangingText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/today"/>
        </RelativeLayout>


        <SeekBar
            android:id="@+id/seekBar_time"
            style="@style/seekbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>


        <Button
            android:id="@+id/button"
            style="@style/buttons"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/create_event_in_calendar"/>


    </LinearLayout>

</RelativeLayout>

Which produces something like this:

enter image description here

I would like to ask how can i catch click outside of the form to hide the app to background?

I tried to set OnClick event to wrapper layout (Parent relative Layout) but this layout is not spread to whole height and width of the screen.

Should I add some other layouts?

How can I solve it please?

Many thanks for any advice

Onik
  • 19,396
  • 14
  • 68
  • 91
redrom
  • 11,502
  • 31
  • 157
  • 264
  • implement touch listener and on ACTION_DOWN cancel the screen whatever it is. If activity then make it finish() or any alertDialog then dismiss it. It would be great if you share the code – asad.qazi Dec 22 '15 at 13:28
  • I tried implement touch listener, but RelativeLayout is not overlaying the whole screen. ACTION_DOWN is some kind of gesture or is not? – redrom Dec 22 '15 at 13:33
  • in java code you are using an activity or what? – asad.qazi Dec 22 '15 at 13:34
  • Yes, activity. MotionEvent.ACTION_DOWN is able to catch in listener which is applied to layout. But if Relative layout has not full width and height is not called. – redrom Dec 22 '15 at 13:42
  • Maybe this can help? http://stackoverflow.com/questions/8384067/how-to-dismiss-the-dialog-with-click-on-outside-of-the-dialog – Abdul Rahman A Samad Dec 22 '15 at 14:04
  • why should't you are using dialog with custom layout it will give you what you are looking for. – Kishan Soni Dec 22 '15 at 14:07

0 Answers0