Ecco lo schema 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="vertical" tools:context="com.example.lab10.MainActivity" > <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="@color/verde" > </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="@color/rosso" > </LinearLayout> </LinearLayout>
Ora il dubbio è: si possono caricare direttamente le immagini su un Layout da xml, nel caso in cui io voglia mettere delle immagini di sfondo?
Fatto! Ho caricato due texture di due diversi tipi di legno.
Prese le immagini e caricatele nella cartella drawable col nome w e w2, ho usato questo codice:
<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="vertical" tools:context="com.example.lab10.MainActivity" > <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="@drawable/w" > </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="@drawable/w3" > </LinearLayout> </LinearLayout>E funziona!!!
...anche sullo smartphone "in carne e ossa":
Nessun commento:
Posta un commento