我有相对布局,即main.xml我设置如下。但现在我必须将 view1 放在 view2 上宽度=200dp 高度=100dp,这样 view2 将成为大视图,而 view1 将成为小视图。
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="@+id/MainPanel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/panel_bottom"
android:layout_gravity="center_horizontal" >
<com.proj.demo.view1
android:id="@+id/sheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignWithParentIfMissing="true"
android:layout_centerInParent="true"
android:layout_toLeftOf="@+id/panel_quick_buttons"
/>
<com.proj.demo.view2
android:id="@+id/sheet2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignWithParentIfMissing="true"
android:layout_centerInParent="true"
android:layout_toLeftOf="@+id/panel_quick_buttons"
/>
</RelativeLayout>
</RelativeLayout>
你想实现什么目标?如果您只想更改宽度和高度,则:
RelativeLayout rl = (RelativeLayout) findViewById(R.id.yourId);
rl.getLayoutParams().height = 100;
rl.getLayoutParams().width = 100;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)