无法在 Android 上全屏显示应用
Unable to display app full screen on Android
我在 activity 中创建了一个图像,然后显示它。但是图像不是全屏的,因为它周围有白色边框!屏幕应该同时显示图像和闪光灯。这是我的 Java 代码:
public class DisplayData extends Activity {
float minBright = 0;
int patch = 25;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
// super.onCreate(savedInstanceState);// no need to write another
//time//
setContentView(R.layout.activity_display);
ViewFlipper imageFlipper = (ViewFlipper)findViewById( R.id.image_flipper );
//I removed the irrelevant part of the code
ImageView image = new ImageView ( getApplicationContext() );
image.setImageBitmap(GridBitmap);
imageFlipper.addView( image );
imageFlipper.setFlipInterval( 2000 );
imageFlipper.startFlipping();
Thread thread = new Thread(){
@Override
public void run() {
while (true) {
try {
synchronized (this) {
wait(bl1);
runOnUiThread(new Runnable() {
@Override
public void run() {
WindowManager.LayoutParams layout = getWindow().getAttributes();
layout.screenBrightness = maxBright;
getWindow().setAttributes(layout);
}
});
}
} catch (InterruptedException e) {
e.printStackTrace();
}
try {
synchronized (this) {
wait(wh1);
runOnUiThread(new Runnable() {
@Override
public void run() {
WindowManager.LayoutParams layout = getWindow().getAttributes();
layout.screenBrightness = minBright;
getWindow().setAttributes(layout);
}
});
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
};
thread.start();
}
}
这是 XML 文件(这只是一个 activity,应用程序包含另一个文件):
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<ViewFlipper
android:id="@+id/image_flipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</ViewFlipper>
</RelativeLayout>
只需从布局中删除内边距即可:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent"
android:layout_height="fill_parent" tools:context=".MainActivity">
<ViewFlipper
android:id="@+id/image_flipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</ViewFlipper>
</RelativeLayout>
我在 activity 中创建了一个图像,然后显示它。但是图像不是全屏的,因为它周围有白色边框!屏幕应该同时显示图像和闪光灯。这是我的 Java 代码:
public class DisplayData extends Activity {
float minBright = 0;
int patch = 25;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
// super.onCreate(savedInstanceState);// no need to write another
//time//
setContentView(R.layout.activity_display);
ViewFlipper imageFlipper = (ViewFlipper)findViewById( R.id.image_flipper );
//I removed the irrelevant part of the code
ImageView image = new ImageView ( getApplicationContext() );
image.setImageBitmap(GridBitmap);
imageFlipper.addView( image );
imageFlipper.setFlipInterval( 2000 );
imageFlipper.startFlipping();
Thread thread = new Thread(){
@Override
public void run() {
while (true) {
try {
synchronized (this) {
wait(bl1);
runOnUiThread(new Runnable() {
@Override
public void run() {
WindowManager.LayoutParams layout = getWindow().getAttributes();
layout.screenBrightness = maxBright;
getWindow().setAttributes(layout);
}
});
}
} catch (InterruptedException e) {
e.printStackTrace();
}
try {
synchronized (this) {
wait(wh1);
runOnUiThread(new Runnable() {
@Override
public void run() {
WindowManager.LayoutParams layout = getWindow().getAttributes();
layout.screenBrightness = minBright;
getWindow().setAttributes(layout);
}
});
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
};
thread.start();
}
}
这是 XML 文件(这只是一个 activity,应用程序包含另一个文件):
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<ViewFlipper
android:id="@+id/image_flipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</ViewFlipper>
</RelativeLayout>
只需从布局中删除内边距即可:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent"
android:layout_height="fill_parent" tools:context=".MainActivity">
<ViewFlipper
android:id="@+id/image_flipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</ViewFlipper>
</RelativeLayout>