2017-03-26 1 views
1

액티비티에서 시작된 프래그먼트가 있습니다. 이제 빈 영역을 터치하면 부모 활동이 변경되었습니다. 영향을받지 않는 버튼이있는 영역 만. 마치 투명하지 않은 것처럼 행동합니다.상위 액티비티에 영향을주는 프래그먼트와의 접촉을 방지하는 방법

방지 할 수있는 방법이 있습니까?

학부모 활동 XML :

<?xml version="1.0" encoding="utf-8" ?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@id/layout_dashboard_parent" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@color/cardview_light_background"> 

    <ScrollView 
     android:id="@id/main_scroll_view" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:layout_alignParentTop="true" 
     android:fillViewport="true"> 

     <LinearLayout 
      android:id="@id/layout_dashboard_scroll_container" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 

      <FrameLayout 
       android:id="@id/dashboard_alert_section" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:visibility="gone"> 

       <include layout="@layout/dashboard_feature_tip_item" /> 
      </FrameLayout> 

      <LinearLayout 
       android:id="@id/main_control_layout" 
       android:layout_width="fill_parent" 
       android:layout_height="611dp"> 

       <LinearLayout 
        android:id="@id/layout_main" 
        style="@style/CardView.Dark" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:background="@color/c_main_back_ground_color" 
        android:gravity="bottom" 
        android:orientation="vertical"> 

        <RelativeLayout 
         android:id="@+id/layout_balance_check" 
         android:layout_width="fill_parent" 
         android:layout_height="120.0dip" 
         android:layout_marginBottom="6.0dip" 
         android:layout_marginEnd="@dimen/dashboard_feature_end_margin_usa" 
         android:layout_marginLeft="@dimen/dashboard_feature_start_margin_usa" 
         android:layout_marginRight="@dimen/dashboard_feature_end_margin_usa" 
         android:layout_marginStart="@dimen/dashboard_feature_start_margin_usa" 
         android:layout_marginTop="@dimen/dashboard_feature_top_margin_usa" 
         android:layout_weight="1.0" 
         android:background="@color/battery_charging_icon_color" 
         android:clickable="true" 
         android:elevation="@dimen/dashboard_feature_bg_elevation" 
         android:focusable="true" 
         android:focusableInTouchMode="false" 
         android:theme="@style/Base.Theme.AppCompat" 
         tools:targetApi="lollipop"> 

         <include 
          layout="@layout/sub_layout_account_cb" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" /> 

         <View 
          android:id="@+id/view" 
          android:layout_width="fill_parent" 
          android:layout_height="fill_parent" 
          android:background="?android:selectableItemBackground" 
          android:duplicateParentState="true" /> 

        </RelativeLayout> 

        <RelativeLayout 
         android:id="@+id/layout_balance_load" 
         android:layout_width="fill_parent" 
         android:layout_height="120.0dip" 
         android:layout_marginBottom="6.0dip" 
         android:layout_marginEnd="@dimen/dashboard_feature_end_margin_usa" 
         android:layout_marginLeft="@dimen/dashboard_feature_start_margin_usa" 
         android:layout_marginRight="@dimen/dashboard_feature_end_margin_usa" 
         android:layout_marginStart="@dimen/dashboard_feature_start_margin_usa" 
         android:layout_weight="1.0" 
         android:background="@color/white" 
         android:clickable="true" 
         android:elevation="@dimen/dashboard_feature_bg_elevation" 
         android:focusable="true" 
         tools:targetApi="lollipop"> 

         <include 
          layout="@layout/sub_layout_account_lb" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" /> 

         <View 
          android:layout_width="fill_parent" 
          android:layout_height="fill_parent" 
          android:background="?android:selectableItemBackground" 
          android:duplicateParentState="true" /> 
        </RelativeLayout> 

        <RelativeLayout 
         android:id="@+id/layout_credit_share" 
         android:layout_width="fill_parent" 
         android:layout_height="120.0dip" 
         android:layout_marginBottom="6.0dip" 
         android:layout_marginEnd="@dimen/dashboard_feature_end_margin_usa" 
         android:layout_marginLeft="@dimen/dashboard_feature_start_margin_usa" 
         android:layout_marginRight="@dimen/dashboard_feature_end_margin_usa" 
         android:layout_marginStart="@dimen/dashboard_feature_start_margin_usa" 
         android:layout_weight="1.0" 
         android:background="@color/white" 
         android:clickable="true" 
         android:elevation="@dimen/dashboard_feature_bg_elevation" 
         android:focusable="true" 
         tools:targetApi="lollipop"> 

         <include 
          layout="@layout/sub_layout_account_sc" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" /> 

         <View 
          android:layout_width="fill_parent" 
          android:layout_height="fill_parent" 
          android:background="?android:selectableItemBackground" 
          android:duplicateParentState="true" /> 
        </RelativeLayout> 

        <RelativeLayout 
         android:id="@+id/layout_credit_barrow" 
         android:layout_width="fill_parent" 
         android:layout_height="120.0dip" 
         android:layout_marginBottom="6.0dip" 
         android:layout_marginEnd="@dimen/dashboard_feature_end_margin_usa" 
         android:layout_marginLeft="@dimen/dashboard_feature_start_margin_usa" 
         android:layout_marginRight="@dimen/dashboard_feature_end_margin_usa" 
         android:layout_marginStart="@dimen/dashboard_feature_start_margin_usa" 
         android:background="@color/white" 
         android:clickable="true" 
         android:elevation="@dimen/dashboard_feature_bg_elevation" 
         android:focusable="true" 
         android:visibility="visible" 
         tools:targetApi="lollipop"> 

         <TextView 
          android:id="@+id/tv_borrow_credit" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_alignLeft="@+id/tv_borrow_credit_warning" 
          android:layout_alignStart="@+id/tv_borrow_credit_warning" 
          android:layout_alignTop="@+id/imageView3" 
          android:text="@string/borrow_credit" 
          android:textColor="@color/c_main_back_ground_color" 
          android:textSize="18sp" 
          android:textStyle="bold" /> 

         <TextView 
          android:id="@+id/tv_borrow_credit_warning" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_alignBottom="@+id/imageView3" 
          android:layout_marginLeft="21dp" 
          android:layout_marginStart="21dp" 
          android:layout_toEndOf="@+id/imageView3" 
          android:layout_toRightOf="@+id/imageView3" 
          android:background="@color/c_main_back_ground_color" 
          android:paddingEnd="5dip" 
          android:paddingLeft="5dip" 
          android:paddingRight="5dip" 
          android:paddingStart="5dip" 
          android:text="@string/borrow_credit_warning" 
          android:textAppearance="@style/TextAppearance.AppCompat" 
          android:textColor="?android:attr/editTextColor" 
          android:textSize="12sp" /> 

         <ImageView 
          android:id="@+id/imageView3" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_alignParentLeft="true" 
          android:layout_alignParentStart="true" 
          android:layout_centerVertical="true" 
          android:layout_marginLeft="21dp" 
          android:layout_marginStart="21dp" 
          android:contentDescription="" 
          app:srcCompat="@drawable/engaging" /> 

         <View 
          android:layout_width="fill_parent" 
          android:layout_height="fill_parent" 
          android:layout_alignParentLeft="true" 
          android:layout_alignParentStart="true" 
          android:layout_alignParentTop="true" 
          android:background="?android:selectableItemBackground" 
          android:duplicateParentState="true" /> 
        </RelativeLayout> 
       </LinearLayout> 
      </LinearLayout> 
     </LinearLayout> 
    </ScrollView> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="10dip" 
     android:layout_gravity="bottom" 
     android:elevation="5dp" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
     app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
     tools:targetApi="lollipop" /> 

    <FrameLayout 
     android:id="@+id/fragment_container" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:animationCache="true"> 

    </FrameLayout> 

    <FrameLayout 
     android:id="@+id/fragment_container_2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="false" 
     android:layout_centerInParent="true" 
     android:animateLayoutChanges="true" 
     android:animationCache="true"> 

    </FrameLayout> 

</RelativeLayout> 

조각의 XML : 당신이 당신의 루트 뷰 클릭을해야 그것에 대해

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/africell_cb_int" 
    android:layout_width="410dp" 
    android:layout_height="wrap_content" 
    android:background="?android:attr/textColorLinkInverse" 
    android:baselineAligned="false" 
    android:orientation="vertical" 
    android:padding="10.0dip" 
    android:weightSum="1.0"> 


    <TextView 
     android:id="@+id/textView8" 
     android:layout_width="332dp" 
     android:layout_height="97dp" 
     android:layout_marginBottom="30dip" 
     tools:ignore="HardcodedText" /> 

    <TextView 
     android:id="@+id/textView6" 
     android:layout_width="330dp" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="30dip" 
     android:text="@string/load_balance_dialog" 
     android:textAlignment="center" 
     android:textColor="@color/black" 
     android:textSize="18sp" /> 

    <android.support.design.widget.TextInputLayout 
     android:layout_width="330dp" 
     android:layout_height="match_parent" 
     android:background="@color/action_button_color" 
     android:clickable="false"> 

     <EditText 
      android:id="@+id/inputField" 
      style="@style/Widget.AppCompat.EditText" 
      android:layout_width="322dp" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_horizontal" 
      android:gravity="center_horizontal" 
      android:hint="@string/edit_text_hint" 
      android:inputType="number" 
      android:textAlignment="textEnd" 
      android:textColor="@color/primary_text_color" 
      android:textStyle="bold" 
      android:maxLines="1" /> 

    </android.support.design.widget.TextInputLayout> 

    <LinearLayout 
     android:layout_width="330dp" 
     android:layout_height="match_parent" 
     android:layout_marginTop="15dp" 
     android:orientation="horizontal"> 

     <Button 
      android:id="@+id/cancel" 
      style="@style/Widget.AppCompat.Button.ButtonBar.AlertDialog" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginEnd="10dp" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="10dp" 
      android:layout_marginStart="5dp" 
      android:layout_weight="0.39" 
      android:text="@string/cancel" 
      android:textColor="@android:color/black" /> 

     <Button 
      android:id="@+id/confirm" 
      style="@style/Widget.AppCompat.Button.ButtonBar.AlertDialog" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginEnd="5dp" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="10dp" 
      android:layout_marginStart="10dp" 
      android:layout_weight="0.36" 
      android:text="@string/confirm" 
      android:textColor="@android:color/black" /> 

    </LinearLayout> 


</LinearLayout> 

답변

2

예. 단지 clickable 속성을 true로 설정하면 아무 것도 쓸 필요가 없습니다. 빈 OnClickListener을 작성하십시오.

android:clickable="true" 

귀하의 조각 xml은 ID가 africell_cb_int 인 루트보기가 있습니다. 클릭 할 수있게하십시오.

+0

감사합니다. –

1

조각 태그 Xml 레이아웃의 루트 태그에 android:clickable="true"을 추가하십시오.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:clickable="true" /> 
관련 문제