2016-05-16 116 views
1

我在我的活動中創建一個圖像,然後顯示它。但圖像並不是全屏,因爲它周圍有一個白色邊框!屏幕應該同時顯示圖像和閃光。這是我的Java代碼:無法在Android上顯示應用程序的全屏幕

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文件(這只是一個活動,該應用程序包含另一個):

<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> 
+1

分享你的xml文件 –

回答

0

剛剛從取出填充你的版式:

<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> 
相關問題