---
title: "How to create Xml layout for Notification activity"  
description: "How to create Xml layout for Notification activity"  
author: "Jonas Stuart"  
published: 2016-06-27  
updated: 2023-06-27  
canonical: https://www.mindstick.com/forum/34148/how-to-create-xml-layout-for-notification-activity  
category: "android"  
tags: ["android", "android layout"]  
reading_time: 2 minutes  

---

# How to create Xml layout for Notification activity

Hi Guys

I am currently working on [android application](https://www.mindstick.com/forum/33405/how-to-get-the-build-version-number-of-your-android-application) please help me to creating [Xml](https://www.mindstick.com/blog/203/working-with-xml-data-in-sql-server) [layout](https://www.mindstick.com/articles/12853/android-layout-and-its-type) for [Notification](https://www.mindstick.com/blog/205/property-notification-in-c-sharp) activity.

## Replies

### Reply by Aryan Kumar

To create an XML layout for a notification activity, you can use the following steps:

- Create a new XML file and give it the name `notification_layout.xml`.
- In the XML file, add the following code:

Code snippet

```plaintext
<?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:orientation="vertical">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="This is a notification"
        android:textSize="20sp" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Open Activity"
        android:onClick="openActivity" />

</LinearLayout>
```

- In the `openActivity()` method, you can add the code to start the activity that you want to open when the user clicks on the button.

Code snippet

```plaintext
public void openActivity(View view) {
    Intent intent = new Intent(this, MainActivity.class);
    startActivity(intent);
}
```

- Save the XML file and compile your project.

When you create a notification, you can use the `setCustomContentView()` method to set the content view of the notification to the XML layout that you created. This will display the notification with the text and button that you defined in the XML layout.

### Reply by Samuel Fernandes

## Hi Jones try this below code

```
<?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:orientation="horizontal" >
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text=" Your notification test is successfull !"
        android:textSize="18sp" />
</LinearLayout>
```


---

Original Source: https://www.mindstick.com/forum/34148/how-to-create-xml-layout-for-notification-activity

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
