Ruhi Goktas
Ruhi Goktas

Reputation: 193

Android Studio set background image for all xmls

I'm a beginner at Android Studio so I need to set background image for all pages. I know how to do it for only one page:

<TableLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentTop="true"
    android:background="@drawable/mypic"> 

But how can I type this once and avoid typing for all the pages?

Upvotes: 0

Views: 295

Answers (2)

Mustansar Saeed
Mustansar Saeed

Reputation: 2790

You can create a separate table_layout.xml and then include that layout in every page.

table_layout.xml

<TableLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentTop="true"
    android:background="@drawable/mypic">

main_activity.xml

<include
    android:id="@+id/table_layout"
    layout="@layout/table_layout" />

<Button
    android:layout_below="@id/table_layout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Text"
    />

Upvotes: 1

curiousMind
curiousMind

Reputation: 2812

you need to do it individually but if more than one attribute which is repeating you can make style of it. and use only that style.

Upvotes: 0

Related Questions