PNG から WebP へ一括変換できるようになった Android Studio 2.3

Androi 4.2.1 - API 17 からフルサポートできる WebP ですが.

夏のアプリ容量ダイエット!WebPでスリムなアプリになろう! - HOME'S Designer's Blog | ホームズ デザイナーズ ブログ

特にこだわる必要のない画像であればかなりのサイズの削減となります.

apk 上でもかなりの削減となり, 端末への転送時間を短縮し, 開発の時間効率も上がることになります.

Android Studio 2.3 (2017-01-04 現在 beta) では, PNG - WebP 変換が一括で容易にできるようになっています.

無造作に, res ディレクトリに配置した画像リソースを右クリックから変換できます.

ディレクトリから一括変換も可能になっています.

と, 削減量や変換後と比較確認しながら簡単にできるようになりました.

WebP から PNG へ再度変換もできるようです.

お試しあれし.


Google Pixel で不具合連発の模様

購入しようと思ってました.

Google Pixel

が, しかし,

ここ数日で, 不具合ネタが連発されています.

「バッテリー残量30%で勝手にシャットダウン」

Some Pixel phones would prematurely shut down at or around 30 percent and would not turn back on until a charger is connected.

Some Google Pixel devices shutting down at 30% battery | AndroidAuthority

Reddit: Some Google Pixel devices shutting down at 30% battery : Android

「スピーカー音声に雑音が入る」

According to a considerable amount of Pixel and Pixel XL users, their phones suffer from a static distortion when the volume is at the three highest levels.

Google Pixel phones may have an audio problem | AndroidAuthority

If you own a Pixel or Pixel XL do you... - Results - Straw Poll

PSA - Currently on my 4th Pixel XL replacement due to an audio issue that appears to affect all Pixels (Video in description) and has not been acknowledged by Google : Android

どちらも, 投稿数や内容から見て事実っぽいし, 以前のNexusシリーズからの不具合を引きずってきているようにも見えます.

Some Nexus 6P devices are affected by bootloop issues

こんなコメントがありました.

I really feel like we are in the age of version release hell.

私たちユーザーもいろいろ考え直す時期なのかも知れません.

まあ, ぶっちゃけると, ポチってから気がついたのですがね...

日本で使える LTE/3G バンド は?


AppCompat 25.1.0 では効かない Android 4.4.x の backgroundTint

最初の私のイメージとしては,

サポートライブラリが充実してきているので ボタンの色は, banckgroundTint で簡単に変更できる!

でしたが...

おさらい

まず, ボタンを設置します.


    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="@android:color/white"
        android:text="Button" />

灰色のボタンが表示されて押したら, それなりにエフェクトが効いて「押されました感」が見て分かります.

ボタンの色を変えます.


    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="@android:color/white"
        android:text="Button"
        android:background="@color/colorAccent" />

ボタンの色が変わりましたが, 押したときにエフェクトが効きません.

background 属性のかわりに backgroudTint を使います.


    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="@android:color/white"
        android:text="Button"
        android:backgroundTint="@color/colorAccent" />

これで, 背景色も変わりかつエフェクトも効きます.

background ではなく, backgroundTint で色を指定する

ということですね.

Button と AppCompatButton の記述

StackOverflow などを見ているとさまざまな記述が見えます.

android - Lollipop's backgroundTint has no effect on a Button - Stack Overflow

ただ「ボタンの色を変えたいだけ」なのですが, なんだか混乱しています.

backgroudTint を使った記述にも似たようなものいくつかあるようです.


    <android.support.v7.widget.AppCompatButton
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="@android:color/white"
        android:text="AppCompatButton"
        android:backgroundTint="@color/colorAccent" />


    <android.support.v7.widget.AppCompatButton
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="@android:color/white"
        android:text="AppCompatButton"
        app:backgroundTint="@color/colorAccent" />

Button のかわりに AppCompatButton を使っていたり, backgroundTint の prefix が android: となっていたり app: になっています.

とりあえず, すべてをレイアウトに記述して表示してみました.

以下3つの挙動は予想通りで同じです.


<Button
    android:backgroundTint="@color/colorAccent"
    ...


<AppCompatButton
    android:backgroundTint="@color/colorAccent"
    ...


<AppCompatButton
    app:backgroundTint="@color/colorAccent"
    ...

Button と記述した場合でも, 内部でいい感じに入れ替えてくれているようですね.

[Tool]-[Android]-[Layout Inspector]

AppCompat を意識すること無く, 昔からの Button を使って記述していけばサポートライブラリが対応してくれるということですね!

AppCompat は えらい!!

Android 4.4 KITKAT で確認する

結果 : 全てダメ.

え,

色とエフェクト両方きちんと反映されているものがない...

なんなんすかね これ...

AppCompat のバージョンを下げてみます.

//compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:appcompat-v7:25.0.1'

Android 4.4 では, backgroudTint が ひとつの記述だけしか意図通りに表示してくれません.

AppCompat はクソ!!

そら混乱もしますわ.

まとめ

backgroundTint についての
OSバージョンと appcompat-v7 バージョンの関係

現状では,

AppCompat-v7 を 25.0.1 で


   <android.support.v7.widget.AppCompatButton
	....
        app:backgroundTint="@color/colorAccent" />

と書いておくのが吉.