读书人

请教在具体的View中设置Layoutparam和

发布时间: 2012-04-20 15:27:03 作者: rapoo

请问在具体的View中设置Layoutparam和在Layout中设置Layoutparam有什么区别
贴上代码

XML code
    <RelativeLayout         android:id="@+id/video_view"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_centerInParent="true"        android:gravity="center">        <VideoView              android:id="@+id/video1"                 android:layout_width="wrap_content"              android:layout_height="wrap_content"               android:layout_centerInParent="true">          </VideoView>            </RelativeLayout>
然后再activity中使用代码改变布局
Java code
            RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(                    320, 240);            lp.addRule(RelativeLayout.CENTER_IN_PARENT);//            videoView1.setLayoutParams(lp);                        RelativeLayout rl = (RelativeLayout) findViewById(R.id.video_view);            rl.setLayoutParams(lp);
这两个的效果是一样的,请问在具体的View中设置Layoutparam和在Layout中设置Layoutparam有什么区别?
谢谢大家了

[解决办法]
没区别。

读书人网 >Android

热点推荐