Android设置横屏、竖屏和全屏显示有两种方式: 1、在Java代码中设置: (1)设置横屏显示: 修改Activity的onResume方法:
@Override protected void onResume() { /** * 设置为横屏 */ if(getRequestedOrientation()!=ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE){ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } super.onResume(); }(2)设置竖屏显示: 修改Activity的onResume方法:
@Override protected void onResume() { /** * 设置为竖屏 */ if(getRequestedOrientation()!= ActivityInfo.SCREEN_ORIENTATION_PORTRAIT){ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } super.onResume(); }(3)设置全屏显示: 在Activity的onCreate方法中的setContentView( )调用之前添加下面代码 :
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //设置无标题 requestWindowFeature(Window.FEATURE_NO_TITLE); //设置全屏 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.main); }2、在xml文件中设置: (1)设置横屏显示: 在AndroidManifest.xml的activity里设置android:screenOrientation的值。
android:screenOrientation="landscape"(2)设置竖屏显示: 在AndroidManifest.xml的activity里设置android:screenOrientation的值。
android:screenOrientation="portrait"(3)设置全屏显示: 在AndroidManifest.xml的activity里设置
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"若只是设置为无标题:
android:theme="@android:style/Theme.NoTitleBar" <script type="text/javascript"> $(function () { $('pre.prettyprint code').each(function () { var lines = $(this).text().split('\n').length; var $numbering = $('<ul/>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('<li/>').text(i)); }; $numbering.fadeIn(1700); }); }); </script>