我的佈局xml文件如下:如果可以做到像對話的setCanceledOnTouchOutside行爲在Android
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="@+id/action_bar_item_list"
android:layout_above="@+id/mybutton"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
<Button
android:id="@+id/mybutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:text="Button" />
<LinearLayout
android:id="@+id/messagelayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical" >
<TextView
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
</RelativeLayout>
如果myButton的被點擊,messagelayout將被設置爲可見。
而雖然messagelayout是可見的,我想做一個函數,如對話框的setCanceledOnTouchOutside做。
當用戶在messagelayout旁邊觸摸屏幕時,它將設置messagelayout消失,而不會做任何其他事情。
如果我不想使用對話框,我該怎麼做?