LoginSignup
6
6

More than 5 years have passed since last update.

Resource ファイル関連のクリーンアップ

Last updated at Posted at 2015-02-02

正規表現による検索

マルチバイトを含む文字のベタ書き

ターゲット

String text = "12あ3";
<View
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="あいうえお" />

正規表現

".*[^\x01-\x7E].*"

カラーコードのベタ書き

ターゲット

<View
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:background="#dddddd" />

正規表現

"#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})"

ターゲット

view.setBackgroundColor(0xffdddddd);

正規表現

0x([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})

Lint によるチェック

[Analyze] - [Inspect Code] - Module 'app' を選択後、OKボタンをクリック。
こんな感じで結果が出ます。

qiita.png

ハードコーディングしているテキスト

プロジェクト名 > Android Lint > Hardcoded text

使用していないリソースの一覧

プロジェクト名 > Android Lint > Unused resources

他にもいろいろとチェックしてくれます。

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6