Working with portrait and landscape mode programmatically in android -


I want to create a layout for both portrait and landscape mode (in Java) and want to change the orientation programmatically in the Java file I am Can anyone help me?

After the text "itemprop =" text ">

you can force a change in the orientation using the program setRequestOrientation (). method of activity class

  public class example activity extends {@Override public zero onCreate (bundled savedInstanceState) {super.onCreate (savedInstanceState); SetContentView (R.layout.main); // --- Changing to Landscape mode --- Setified Orientation (Activity Infoda. SCREEN_ORIENTATION_LANDSCAPE); To change to portfolio mode,  ActivityInfo. SCREEN_ORIENTATION_PORTRAIT  Stable:  

Use, for more information, see.

Edit

You can add orientation in your specific activity to AndroidManifest.xml Can: & lt; Activity Android: Name = "Demo Activity" Android: label = "@ string / app_name" Android: Screen Orientation = "Portrait" & gt;

As far as the layout is concerned, it is the best suggestion to create different folders under res / For example, For res / layout-port and res / layout-land for landscape.

Comments

Popular posts from this blog

java - NullPointerException for a 2d Array -

python - Assemble mpeg file unable to play in mediaplayer -

c# - NameSpace Manager or XsltContent to parse aspx page -