Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 590261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:30:35+00:00 2026-05-13T15:30:35+00:00

I have an app with a widget but I am having some difficulty with

  • 0

I have an app with a widget but I am having some difficulty with the layout of the widget.

The basic idea if the widget should look like an icon and have a little text tag under it like any other icon on the desktop.

I found one example which uses an android:background for the TextView and uses a drawable XML:

<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#AA111111"/>
<padding android:left="5dp" 
  android:right="5dp"
  android:bottom="1dp" 
  android:top="1dp" />
<corners android:radius="8dp" />
</shape>

However this does not work brilliantly, the text just isn’t the same as the other icons on the desktop and when you rotate the phone part of the text is chopped off!

The next problem is selecting the widget, I use an ImageButton as the icon – with the android:background set to a transparent image. I have been using another drawable xml file which allows me to change the image when the widget is selected. However I would prefer the default action of an icon, where the square around the icon turns orange.

How would I achive these two effect – I know it is possible somehow as the app “sms unread count” achives exactly what I want to happen!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T15:30:36+00:00Added an answer on May 13, 2026 at 3:30 pm

    I would do something like:

    <LinearLayout>
        <ImageView/>
        <TextView/>
    </LinearLayout>
    

    LinearLayout’s background would be a <selector> aka StateListDrawable. The selector would specify a transparent background, that changes to orange when selected.

    LinearLayout would also be the View you would set your PendingIntent on so that the user can click anywhere in the view and it will register as an onClick event.

    As for your layout issues, you are just going to have to play with the layout to get the image and text to look like other icons on the home screen. I would think it wouldn’t be that difficult to get a horizontally centered ImageView with a horizontally centered TextView below it, then just tweak the image dimensions and the text size till they look just like other icons on the home screen.

    As for the problem you are seeing when you switch to Landscape view on your home screen, you will need to provide a landscape version of your layout XML file tweaked to display correctly in landscape mode. See my answer to this question for the method of doing that. When I make app widgets I usually get the portrait view looking perfect, then copy that layout file to the layout-land directory and start making tweaks until it looks like I want it to in landscape as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an app with an extensive admin section. We got a little trigger
I have an app using PHP and the PayPal API. The basic way it
I have an app that needs to open a new window (in the same
I have an app with a large ListView which is terribly slow so I'm
I have an app written in C# that lies on a network share. When
I have an app which could benefit from the user being able to choose
I have an app where I create many uiviews and add them to the
I have an app that executes commands on a Linux server via SSH just
I have a app that I'm deploying to a development server using Capistrano. I'd
I have an app that is failing on the install. The vendor says I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.