Android action bar高度要如何取得?

因為車用電子的工作實在太忙了,
都沒有時間寫app....
在這樣下去可能android app知識都會忘了....
所以,今天難得放假,先把手中工作撇開...
立了個目標要把taipei mrt map加入 action bar,
但action bar高度要如何取得?
不然地圖不會垂直置中...
參考這篇文章:http://www.exsoul-browser.com/2012/11/30/how-to-get-action-bar-height/
真的可以用...
我把他獨立成一個static function.
只要傳入context即可.

    static int get_action_bar_height(Context ctx) {
        int height = 0;
        TypedValue typeValue = new TypedValue();
        ctx.getTheme().resolveAttribute(android.R.attr.actionBarSize,
                typeValue, true);
        height = TypedValue.complexToDimensionPixelSize(typeValue.data, ctx
                .getResources().getDisplayMetrics());

        Log.d(tag, "action bar height=" + height);
        return height;
    }


呼叫的方法即:
get_action_bar_height(this);

留言

這個網誌中的熱門文章

最爛的銀行服務-玉山銀行

Mark App Design Apps - Terms and Privacy Policy (服務條款,隱私權政策)

SMR疊瓦式hdd致命缺陷被解決????!!!

ios app 上架時app icon要注意事項

更改google drive預設存放目錄位置Change Google Drive Default Folder Location in Windows

舊有app在Android 12 閃退問題& app Splash screens

google play 正式發布前測試報告...非常好用.

app bundle and bundletool. 關於aab安裝問題

關於google play console app應用程式簽署

Google Play badge徽章產生器