我希望能够通过编程获取可见布局的准确高度,如图所示。 我使用了Sherlock片段活动作为主要活动,其中包含不同的片段。 我试图通过Display和display matrix来获取屏幕的高度和宽度,但它只提供整个屏幕的高度和宽度。 但我想要获取子活动的可见视图。 请帮帮我。 提前感谢您。
主XML(选项卡栏)
<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(子Activity的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>