Wednesday, 14 August 2013

android priority of the layout and no reaction from the code? (visible / invisible on imgView)

android priority of the layout and no reaction from the code? (visible /
invisible on imgView)

why does only my xml layout work and have priority over the code inside
OnCreate ? I am trying to make an imageview visible/invisible, but only
the layout can make it, would you know why?
It is just a linearLayout vertical with :
<ImageView
android:id="@+id/friendsButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
android:src="@drawable/friends_button" />
The whole xml :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:id="@+id/welcome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="86dp"
android:layout_marginTop="10dp"
android:orientation="vertical"
>
<TextView
android:id="@+id/textRequest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<ImageView
android:id="@+id/playButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/play_button" />
<ImageView
android:id="@+id/friendsButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
android:src="@drawable/friends_button" />
</LinearLayout>
</RelativeLayout>
and friendsButton.setVisibility(View.INVISIBLE); in OnCreate
I tried to put it invisible in the layout and Visible in the code, but
still the same priority to the layout...
Any idea?
Thanks

No comments:

Post a Comment