2017-01-11 6 views
0

私は、アクションバーとページの残りの部分を取るレイアウトを持っているページを持っている。私はページの残りの部分の高さを知りたいです - それはSCREEN_HEIGHT - STATUS_BAR_HEIGHT - ACTION_BAR_HEIGHTです。ページの高さを取得する

platform.screen.mainScreen.heightDIPsからSCREEN_HEIGHTを取得できます。

STATUS_BARとACTION_BARの高さはどのようにして取得できますか?

私は高さまたはgetMeasuredHeightを(やろう)、私はブラッドからの回答を使用して0

+0

android:https://gist.github.com/hamakn/8939eb68a920a6d7a498私は.tsや.jsに翻訳する手助けをする時間がありませんが、それはアンドロイドのアプローチの1つです。 –

答えて

2

を取得し、ここでTSコードだ

 let resource_id = application.android.foregroundActivity.getResources().getIdentifier("status_bar_height", "dimen", "android"); 

    if (resource_id > 0) 
     console.log("status_bar_height=" + application.android.foregroundActivity.getResources().getDimensionPixelSize(resource_id)); 

    // android.content.res.TypedArray 

    let array = application.android.foregroundActivity.getTheme().obtainStyledAttributes([ android.R.attr.actionBarSize ]); 

    console.log("actionBarHeight=" + array.getDimension(0,0)); 

返された値が実際のピクセルであるように見えます。

DIP値が必要な場合は、platformModule.screen.mainScreen.scaleで除算します。

関連する問題