Reputation: 4559
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
I want my widget appears as below screenshot with text at the bottom showing the name of my app
Upvotes: 0
Views: 344
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