我想在onCreate()方法中获取Middle(Body)布局的高度/宽度。Android:获取主体布局的大小动态
我的main.xml是:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rl_Main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/main_bg11" >
<RelativeLayout
android:id="@+id/rl_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" >
<include layout="@layout/title" />
</RelativeLayout>
<ScrollView
android:id="@+id/svtest"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/rl_music_controller"
android:layout_below="@+id/rl_title" >
<RelativeLayout
android:id="@+id/rl12"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >
<TableLayout
android:id="@+id/tbl_vandana"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="center_horizontal"
android:paddingTop="30dp" >
</TableLayout>
</RelativeLayout>
</ScrollView>
<RelativeLayout
android:id="@+id/rl_music_controller"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<include layout="@layout/controller" />
</RelativeLayout>
我在TableLayout动态添加的TextView。 ID:
rl_title是我的标题布局
svtest是我的中间(身体)的内容。
rl_music_controller是我的页脚布局。
我指的是this link。但我并不完全明白我在做什么?
你有没有试过这个http://stackoverflow.com/questions/12068945/get-layout-height-and-width-at-run-time-android? – sandrstar
我有设备的高度/宽度通过使用“显示”类。 – Lawrance
根据你的问题你需要svtest布局的大小,对吧? – sandrstar