2013-09-20 3 views
1

так что я этот XML макет:Android Layout setVisibility не применяется

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#fff" 
    android:orientation="vertical" > 



    <FrameLayout 
     android:id="@+id/screen" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" > 


     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:background="#fff" 
      android:orientation="vertical" > 


      <RelativeLayout 
       android:id="@+id/ltitle" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="0" 
       android:background="#4c4c4c" 
       android:gravity="center_vertical" 
       android:orientation="horizontal" > 

       <TextView 
        android:id="@+id/textView1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="10dp" 
        android:paddingBottom="5dp" 
        android:paddingLeft="5dp" 
        android:paddingTop="5dp" 
        android:text="TARIFICATIONS VERS LE " 
        android:textColor="#f7f7f7" /> 

       <TextView 
        android:id="@+id/title" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true" 
        android:layout_toRightOf="@+id/textView1" 
        android:paddingBottom="5dp" 
        android:paddingTop="5dp" 
        android:text="MAROC " 
        android:textColor="#fda02c" /> 

       <ImageView 
        android:id="@+id/recherche2" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentRight="true" 
        android:layout_centerVertical="true" 
        android:layout_weight="0" 
        android:paddingLeft="10dp" 
        android:paddingRight="15dp" 
        android:src="@drawable/icon_recherche_input" /> 
      </RelativeLayout> 
     </LinearLayout> 
    </FrameLayout> 


    <LinearLayout 
     android:id="@+id/search" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentRight="true" 
     android:layout_marginTop="60dp" 
     android:orientation="vertical" 
     android:visibility="invisible" > 


     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="#2d2d2d" 
      android:orientation="vertical" 
      android:padding="5dp" > 

      <AutoCompleteTextView 
       android:id="@+id/autoCompleteTextView1" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:background="@drawable/recherche" 
       android:ems="10" 
       android:hint="Search" 
       android:paddingBottom="5dp" 
       android:paddingLeft="30dp" 
       android:paddingTop="5dp" 
       android:textColor="#cacaca" 
       android:textColorHint="#cacaca" 
       android:textSize="@dimen/recherche" /> 

      <ImageView 
       android:id="@+id/imageView3" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignLeft="@+id/autoCompleteTextView1" 
       android:layout_centerVertical="true" 
       android:layout_marginLeft="5dp" 
       android:src="@drawable/icon_recherche_input" /> 
     </RelativeLayout> 


    </LinearLayout> 
</RelativeLayout> 

, когда я нажимаю на ImageView "recherche2", чтобы сделать макет "поиск" видно, ничего не происходит

@Override 
public void onClick(View v) { 
    switch (v.getId()) { 
    case R.id.recherche2: 
     if (!(Boolean) recherche2.getTag()) { 
      recherche2.setTag(true); 
      search.setVisibility(View.VISIBLE); 
      screen.getForeground().setAlpha(100); 
     } else { 
      recherche2.setTag(false); 
      search.setVisibility(View.INVISIBLE); 
      screen.getForeground().setAlpha(0); 
     } 
     break; 
    } 
} 

по способ изменения переднего плана, но макет все еще невидим.

если кто-нибудь имеет понятие о том, что происходит, это будет гораздо appreiated, спасибо

+0

Он отображается в редакторе, если вы установите его на 'visible'? Кроме того, 'RelativeLayout' не имеет свойства' orientation'. – codeMagic

+0

Вы установили OnClickListener в свой ImageView? –

+0

Хотя это может и не решить вашу проблему: ваш вызов 'setAlpha()' неверен, максимальное значение равно 1, см. [Здесь] (http://developer.android.com/reference/android/view/View.html # setAlpha% 28float% 29) – avalancha

ответ

0

Мне кажется, вы не должны быть установки переднего плана screen макета, но фон вместо этого.

Кроме того, вы должны позвонить по телефону postInvalidate() на ваш макет screen после переключения, чтобы обеспечить его перерисовку в результате щелчка.

+0

не повезло, не получилось, передний план меняется, но макета нет –

Смежные вопросы