layout android code example

Example 1: code to include layout from java in android

<ViewStub
    android:id="@+id/layout_stub"
    android:inflatedId="@+id/message_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="0.75" />

Example 2: code to include layout from java in android

ViewStub stub = (ViewStub) findViewById(R.id.layout_stub);
stub.setLayoutResource(R.layout.whatever_layout_you_want);
View inflated = stub.inflate();

Example 3: comment regler haut et le bas page xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" >
  <Button  
    android:id="@+id/premier"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="Premier bouton" />
    
  <Button  
    android:id="@+id/second"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="Second bouton" />
</LinearLayout>