5
Ho un layout relativo, ad esempio main.xml, che ho impostato come segue. Ma ora devo mettere view1 su view2 con width = 200dp e height = 100dp, in modo che view2 sia grande e view1 sia piccolo su di esso.Modifica del layout relativo a livello di programmazione
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>
quindi chiamare invalidate() da rl in seguito. –
Grazie, ha funzionato perfettamente per me. – user1400285
Non succede nulla quando chiamo rl.invalidate(). Ma cambierà dopo aver fatto scorrere lo schermo. Ad ogni modo per rinfrescare l'intero massetto? –