jovs
jovs

Reputation: 483

setvisibility change once screen orietantion changed

im having problem with the setvisibility on android once orientation is changed.

on my login screen i got this code:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:fb="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="#efefef"
android:orientation="vertical"
tools:context=".MainActivity" >


 <ImageView
     android:id="@+id/logo"
     android:layout_width="fill_parent"
     android:layout_height="300dp"
     android:layout_alignParentLeft="true"
     android:layout_alignParentTop="true"
     android:layout_marginTop="168dp"
     android:src="@drawable/logo" />

 <android.support.v4.view.ViewPager
     android:id="@+id/pager"
     android:layout_width="wrap_content"
     android:layout_height="300dp"
     android:layout_alignParentLeft="true"
     android:layout_alignTop="@+id/logo"
     android:background="@color/blue"
     android:visibility="invisible" >
 </android.support.v4.view.ViewPager>

 <com.facebook.widget.LoginButton
     android:id="@+id/facebook_login"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_below="@+id/logo"
     android:layout_centerHorizontal="true"
     android:layout_marginTop="41dp"
     fb:login_text="Connect Facebook" />

 <ImageView
     android:id="@+id/share"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_above="@+id/pager"
     android:layout_centerHorizontal="true"
     android:layout_marginBottom="25dp"
     android:src="@drawable/fb_share"
     android:visibility="invisible" />

</RelativeLayout>

enter image description here

once authenticated, it will enter image description hereshow this page.

but once i changed it to landscape orientation, the logo is visible and the view pager was invisble

enter image description here

is there anything im missing?

Upvotes: 0

Views: 58

Answers (2)

Rajendra
Rajendra

Reputation: 127

you need to add this line in your AndroidManifest.xml file.

android:configChanges="keyboard|keyboardHidden|orientation|screenSize"

Because whenever you have change orientation from portrait to landscape at that time activity will be recreated and also its states. So you have to do this one

Upvotes: 1

Liem Vo
Liem Vo

Reputation: 5319

In your Manifest, in the activity of that view, please add following code.

android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"

Upvotes: 0

Related Questions