Android中Activity不再全屏的处理【安卓进化三十一】
Activity可以设置屏幕不再是全屏,设置dialog的样式就可以了,加载drawable的xml文件,别忘了在manifest中设置主题样式,引用这个style样式,说明一下:在onCreate()方法中是保持activity一直处于显示效果,不会进入休眠状态。转载标明出处:
http://blog.csdn.net/wdaming1986/article/details/6850186
看效果图:白色部分为activity中的不是全屏的效果:
在FullScreamActivity工程下面:
www.zzzyk.com
com.cn.daming包下面:MainActivityFullScream.java中的代码:
view plaincopy to clipboardprint?
package com.cn.daming;
import android.app.Activity;
import android.os.Bundle;
import android.view.WindowManager;
public class MainActivityFullScream extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//make the screen always on
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.main);
}
}
package com.cn.daming;
import android.app.Activity;
import android.os.Bundle;
import android.view.WindowManager;
public class MainActivityFullScream extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//make the screen always on
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.main);
}
}
main.xml中的代码:
view plaincopy to clipboardprint?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/daming_text_view"
/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/daming_text_view"
/>
</LinearLayout>
在values目录下面加入style.xml的文件,代码如下:
view plaincopy to clipboardprint?
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.AndroidDm"
parent="android:style/Theme.Dialog">
<item name="android:windowBackground">
@drawable/dmbg</item>
</style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.AndroidDm"
parent="android:style/Theme.Dialog">
<item name="android:windowBackground">
@drawable/dmbg</item>
</style>
</resources>
在Drawable中加入dmbg.xml文件,代码如下:
view plaincopy to clipboardprint?
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<padding android:left="15dp" android:top="-35dp"
android:righ
补充:移动开发 , Android ,