JavascriptProva

venerdì 8 gennaio 2016

Inclusione di un LinearLayout su xml esterno nel LinearLayout dell'activity principale, mediante xml.

Ecco come ho creato un LinearLayout contenente tre LinearLayout, di cui uno esterno incluso, il tutto tramite manipolazione dell'xml.

activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    tools:context="com.example.lab10.MainActivity" >

 <LinearLayout 
      android:layout_width="0dp"
      android:layout_height="match_parent"
      android:layout_weight="1"
      android:background="@drawable/w" >
 </LinearLayout>
 
 <include layout="@layout/hills" 
     android:layout_width="0dp"
     android:layout_height="match_parent"
     android:layout_weight="1" /> 
    
 <LinearLayout 
      android:layout_width="0dp"
      android:layout_height="match_parent"
      android:layout_weight="1"
      android:background="@drawable/w3" >  
 </LinearLayout>
</LinearLayout> 
la parte marcata in giallo è l'inclusione dell'xml esterno.

hills.xml (xml esterno)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/hills"
    android:orientation="vertical" >
</LinearLayout> 
...e il risultato è perfetto!

Nessun commento:

Posta un commento