开发者

On click function for the border greyed around the activity?

On click function for the border greyed around the activity?

In the attached screenshot, the grey areas around the activity are translucent and have activity is shown with the following xml.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" 
    android:layout_height="fill_parent" android:background="@color/candidate_normal" android:scrollX="-100dp" 
    android:scrollY="-100dp" android:onClick="backgrndListner">
    <LinearLayout android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" 
        android:background="@drawable/overlay1" android:clickable="false">
        <LinearLayout android:layout_width="1100dp" android:layout_height="wrap_content" android:orientation="horizontal">
            <ImageButton android:id="@+id/homeButton" android:src="@drawable/home" android:layout_width="wrap_content" 
                android:layout_height="wrap_content" android:clickable="true"/>
            <LinearLayout android:layout_width="1100dp" android:layout_height="wrap_content" android:orientation="horizontal">
                <TextView android:textSize="18dp" android:text="Header" android:editable="true" android:layout_height="wrap_content" 
                    android:layout_width="wrap_content" android:id="@+id/headerInfo" android:layout_marginLeft="25dp"
                    android:layout_marginTop="2dp"/>
                <TextView android:id="@+id/yellowCardItem" android:textSize="30dp" android:textStyle="bold" 
                    android:text="Yellow Card Item"  android:layout_marginTop="25dp" android:layout_marginLeft="300dp" 
                    android:layout_height="wrap_content" android:layout_width="wrap_content" android:gravity="center_horizontal"/>
            </LinearLayout>
            <ImageButton android:id="@+id/statusComplete" android:src="@drawable/notification_done_red" android:layout_width="wrap_content" 
                android:layout_height="wrap_content" android:layout_gravity="right|top"/>
        </LinearLayout>
        <LinearLayout android:layout_width="1100dp" android:layout_height="wrap_content" android:orientation="vertical">
            <TextView android:id="@+id/yellowCardDescription" android:textSize="20dp" android:padding="30dp" 
                android:layout_marginLeft="50dp" android:layout_marginRight="50dp"
                android:layout_width="wrap_content" android:layout_height="300dp" android:gravity="center_horizontal"
                 android:text="Description should come here" android:textColor="#FF0000"/>
        </LinearLayout>
        <LinearLayout android:id="@+id/mediaItems" android:layout_width="match_parent" android:layout_height="wrap_content" 
            android:orientation="horizontal" android:layout_marginLeft="200dp">
        </LinearLayout>
        <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"
            android:layout_marginTop="10dp">
            <ImageButton android:id="@+id/share" android:src="@drawable/share" android:layout_width="wrap_content" 
                android:layout_height="wrap_content" android:clickable="true" android:layout_gravity="right|top" android:layout_marginLeft="1185dp"/>
        </LinearLayout>
    </LinearLayout>

The problem that I am facing is that whenever I touch the white area(where the activity is present) it senses the backgrndListner which I just want for the areas in grey(highlighted in red colors). I just want the touch to be activated for the area outside the white activity area for hte complete screen.

Any help would be really appreciate开发者_JAVA百科d.

yout>


I think you need to prevent the inside view from propagating the touch event. So you could try to add an id to the 2nd LinearLayout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" 
    android:layout_height="fill_parent" android:background="@color/candidate_normal" android:scrollX="-100dp" 
    android:scrollY="-100dp" android:onClick="backgrndListner">
    <LinearLayout android:id="@+id/ignorebox" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" 
        android:background="@drawable/overlay1" android:clickable="false">

and then in your onCreate try this:

findViewById(R.id.ignorebox).setOnTouchListener(new View.OnTouchListener(){
  public boolean onTouch(View v, MotionEvent event){ return true; }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜