2014-03-27 96 views
0

容器視圖後,仍然可點擊我有一個LinearLayout是在FrameLayout視圖。這LinearLayout坐在框架的頂部。安卓:意見容器設置爲View.GONE

在這個LinearLayout,也有一些TextView S中的點擊。當我將LinearLayout設置爲View.GONE時,除了TextView仍然可點擊之外,所有內容都按預期方式消失

這是爲什麼?除了將所有可點擊的TextView s設置爲View.GONE之外,我該如何避免它?

XML

<FrameLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" > 

    <LinearLayout 
     android:id="@+id/fragment_container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" /> 

    <LinearLayout 
     android:id="@+id/match_settings_container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:background="#40c0a9" 
     android:visibility="gone" 
     android:padding="10dp" > 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="10dp" 
      android:orientation="horizontal" 
      android:baselineAligned="false" > 

      <LinearLayout 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:layout_gravity="center_vertical" 
       android:orientation="vertical" > 

       <com.walintukai.lfdate.CustomFontTextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginRight="10dp" 
        android:textSize="20sp" 
        android:textColor="#fff" 
        android:text="@string/lbl_age" /> 

      </LinearLayout> 

      <LinearLayout 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="2" 
       android:orientation="vertical" > 

       <com.walintukai.lfdate.CustomFontBoldTextView 
        android:id="@+id/age_setting" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:background="@drawable/white_rounded_bg" 
        android:padding="6dp" 
        android:textSize="20sp" 
        android:textColor="#0099cb" 
        android:text="18 to 99" /> 

      </LinearLayout> 

     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="10dp" 
      android:orientation="horizontal" 
      android:baselineAligned="false" > 

      <LinearLayout 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:layout_gravity="center_vertical" 
       android:orientation="vertical" > 

       <com.walintukai.lfdate.CustomFontTextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginRight="10dp" 
        android:textSize="20sp" 
        android:textColor="#fff" 
        android:text="@string/lbl_location" /> 

      </LinearLayout> 

      <LinearLayout 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="2" 
       android:orientation="vertical" > 

       <com.walintukai.lfdate.CustomFontBoldTextView 
        android:id="@+id/location_setting" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:background="@drawable/white_rounded_bg" 
        android:padding="6dp" 
        android:textSize="20sp" 
        android:textColor="#0099cb" 
        android:text="Any Distance" /> 

      </LinearLayout> 

     </LinearLayout> 

    </LinearLayout> 

</FrameLayout> 

活動

// Handles expanding match settings window 
    final ToggleButton btnShowMatchSettings = (ToggleButton) findViewById(R.id.btn_show_match_settings); 
    btnShowMatchSettings.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { 
     LinearLayout container = (LinearLayout) findViewById(R.id.match_settings_container); 

     @Override 
     public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 
      if (isChecked) { 
       btnShowMatchSettings.setBackgroundResource(R.drawable.ico_menu_open); 
       container.setAnimation(AnimationUtils.loadAnimation(DashboardActivity.this, R.anim.slide_down)); 
       container.setVisibility(View.VISIBLE); 

       ageSetting = (CustomFontBoldTextView) findViewById(R.id.age_setting); 
       ageSetting.setVisibility(View.VISIBLE); 
       ageSetting.setOnClickListener(new OnClickListener() { 
        @Override 
        public void onClick(View v) { 
         new AgePickerDialog().show(getFragmentManager(), "agePicker"); 
        } 
       }); 

       locationSetting = (CustomFontBoldTextView) findViewById(R.id.location_setting); 
       locationSetting.setVisibility(View.VISIBLE); 
       locationSetting.setOnClickListener(new OnClickListener() { 
        @Override 
        public void onClick(View v) { 
         new LocationPickerDialog().show(getFragmentManager(), "locationPicker"); 
        } 
       }); 
      } 
      else { 
       btnShowMatchSettings.setBackgroundResource(R.drawable.ico_menu); 
       container.setAnimation(AnimationUtils.loadAnimation(DashboardActivity.this, R.anim.slide_up)); 
       container.setVisibility(View.GONE); 
       ageSetting.setVisibility(View.GONE); 
       locationSetting.setVisibility(View.GONE); 
      } 
     } 
    }); 
} 

回答

1

您更改視圖的知名度並不意味着它們被破壞的事實。 你應該嘗試添加這樣的事情

yourButton.setClickable(假);