首页 > 代码库 > Android 设置横屏或竖屏

Android 设置横屏或竖屏

private void init() {     Button landButton = (Button) findViewById(R.id.landbutton);    landButton.setOnClickListener(new ClickListenerlandButton());    Button VButton = (Button) findViewById(R.id.Vbutton);    VButton.setOnClickListener(new ClickListenerVButton());}private class ClickListenerlandButton implements OnClickListener {    @Override    public void onClick(View v) {        landScreen();    }}private  void landScreen(){    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);//横屏}private class ClickListenerVButton implements OnClickListener {    @Override    public void onClick(View v) {        VScreen();    }}private  void VScreen(){    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//竖屏}

  

Android 设置横屏或竖屏