I have a relativelayout inside a relativelayout, and all this inside an include. External relativelayout has android: background, which is an image.
The inside has a different image, but the same.
All this is invisible. There is a button that is responsible for changing visibility.
When it becomes visible, the internal image is displayed, but the external image is not.
BUT, if I click to hide, and then click again to show - the external image is also displayed.
Here is the corresponding xml:
<RelativeLayout
android:id="@+id/display_prefs_dialog_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="invisible" >
<include
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="45dp"
android:layout_marginRight="50dp"
layout="@layout/display_prefs_dialog" >
</include>
</RelativeLayout>
And inside include include:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/display_prefs_dialog"
android:layout_width="327dp"
android:layout_height="218dp"
android:background="@drawable/display_win" >
<RelativeLayout
android:id="@+id/display_letters_bg"
android:layout_width="262dp"
android:layout_height="44dp"
android:layout_marginLeft="32dp"
android:layout_marginTop="38dp"
android:background="@drawable/display_letter_frame" >
JAVA Code:
final ImageButton btnDisplay = (ImageButton) findViewById(R.id.btnDisplay);
final RelativeLayout prefsInnerDialog = (RelativeLayout) findViewById(R.id.display_prefs_dialog);
final RelativeLayout prefsDialog = (RelativeLayout) findViewById(R.id.display_prefs_dialog_layout);
btnDisplay.setOnClickListener(new Button.OnClickListener()
{
public void onClick(View v)
{
int visibility = prefsDialog.getVisibility();
if (visibility == View.VISIBLE)
{
prefsDialog.setVisibility(View.INVISIBLE);
}
else
{
prefsDialog.setVisibility(View.VISIBLE);
}
}
});
source
share