1

私はAndroid 4.4.2用のカスタムランチャーをビルドし、壁紙にいくつかの問題があります。新しい壁紙を設定すると、すべての画像が画面にフィットしますが、デバイスをリロードすると壁紙が拡大され、画面サイズと画像サイズがデフォルトで同じであっても唯一の中央部分が表示されます。 これは複数の画面モードのためだと思いますが、わかりません。今は、ACTION_BOOTイベントの放送受信機で毎回壁紙をリセットしますが、いくつかの遅れがあり、洗練されたソリューションのようには見えません。 私は設定して、このクラスで壁紙をリロード:再起動後の壁紙のサイズ変更

public class WallpaperUtils { 

public static final String PREF_CUSTOM_WALLPAPER = "PREF_CUSTOM_WALLPAPER"; 
public static final String PREF_WALLPAPER_RES = "PREF_WALLPAPER_RES"; 

public static void reloadWallpaper(Context context) { 
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); 
    boolean isCustomWallpaper = prefs.getBoolean(PREF_CUSTOM_WALLPAPER, false); 

    if (isCustomWallpaper) { 
     int wallRes = prefs.getInt(PREF_WALLPAPER_RES, 0); 
     setWallpaper(context, wallRes); 
    } 


} 

public static void setWallpaper(Context context, int wallRes) { 

    WallpaperManager manager = WallpaperManager.getInstance(context.getApplicationContext()); 

    WindowManager window = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); 

    DisplayMetrics metrics = new DisplayMetrics(); 
    window.getDefaultDisplay().getMetrics(metrics); 

    int width = metrics.widthPixels; 
    int height = metrics.heightPixels; 

    Bitmap tempBitmap = BitmapFactory.decodeResource(context.getResources(), wallRes); 
    Bitmap bitmap = Bitmap.createScaledBitmap(tempBitmap, width, height, true); 

    manager.setWallpaperOffsetSteps(1, 1); 
    manager.suggestDesiredDimensions(width, height); 

    try { 
     manager.setBitmap(bitmap); 
    } catch (IOException e) { 
     e.printStackTrace(); 
    } 
} 

}

とAndroidManifestのホーム画面では、次のようになります。あまりにもデフォルトのランチャー壁紙スケールで

<activity 
     android:name=".ui.main.MainActivity" 
     android:launchMode="singleTask" 
     android:screenOrientation="landscape" 
     android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.HOME" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 

ので、私は考えていませんそのスタイルの問題ですが、どこに問題があるのか​​わかりません。

答えて

0

アンドロイドのテーマやスタイルについて調査したところ、間違っていることがわかります。

@android:スタイル/テーマ

は廃止され、だから私はちょうどONSTARTコールバック経由でホーム画面の活動の壁紙を取得するAPI 11

後に使用することをお勧めしません。メインのレイアウトの背景として設定します。

関連する問題