AndroidDev
AndroidDev

Reputation: 4559

How to show app name along with an widget

I have created a widget for my app. Everything works fine, but the only thing I want to display in my widget is the name of my app at the bottom of my widget with transparent background. I tried a lot but the name of my app always appear inside my widget only. I am sending my code and the screen Shots that describing what I want.

The Layout I have used:

WidgetLayout.xml file:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/appwidget_bg_clickable" >

<ImageView
    android:id="@+id/backgroundImage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:contentDescription="@string/tracking_status_faq_imageview_text"
    android:scaleType="fitXY" />

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:gravity="center_horizontal|center_vertical" >

    <TextView
        android:id="@+id/txt_date"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#5f5f5f"
        android:textSize="14dp" >
    </TextView>
</LinearLayout>

</RelativeLayout>

My widget appears as

enter image description here

I want my widget appears as below screenshot with text at the bottom showing the name of my app

enter image description here

Upvotes: 0

Views: 344

Answers (1)

Arie
Arie

Reputation: 5373

Try:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:gravity="center"
    android:background="@android:color/transparent">
<RelativeLayout
    android:id="@+id/widget"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/appwidget_bg_clickable" >

<ImageView
    android:id="@+id/backgroundImage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:contentDescription="@string/tracking_status_faq_imageview_text"
    android:scaleType="fitXY" />

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:gravity="center_horizontal|center_vertical" >

    <TextView
        android:id="@+id/txt_date"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#5f5f5f"
        android:textSize="14dp" >
    </TextView>
</LinearLayout>
</RelativeLayout>
<TextView
   android:id="@+id/txt_label"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="some text">
</TextView>
</LinearLayout>

Upvotes: 1

Related Questions