Я хочу получить точную высоту видимого макета программно, как показано на рисунке. Я использовал активность фрагмента Шерлока как основной вид деятельности, который содержит разные фрагменты. Я попытался получить высоту и ширину экрана с помощью Display and display matrix, но он дает высоту и ширину всего экрана. Но я хочу получить только видимый вид активности ребенка. пожалуйста помогите. заранее спасибо.Android Получить высоту видимого макета программно
Главная XML (из TabBar)
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="@dimen/fr_layout_width"
android:layout_height="@dimen/fr_layout_height"
android:layout_weight="0" />
<FrameLayout
android:id="@+android:id/realtabcontent"
android:layout_width="fill_parent"
android:layout_height="@dimen/fr_layout_height"
android:layout_weight="1" />
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="@dimen/hdpi_tab_layout_height"
android:layout_weight="0"
android:background="@android:color/transparent"
android:gravity="bottom"
android:orientation="horizontal" />
</LinearLayout>
</TabHost>
</android.support.v4.widget.DrawerLayout>
ребенок XML (Xml детской деятельности)
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mainscroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".MainActivity">
<LinearLayout
android:id="@+id/topliner"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
</LinearLayout>
</ScrollView>
Я попробовал это раньше, но он дает всю высоту экрана. кстати, 'getHeight();' устарел с тех пор, как API 13 –