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 7496559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:40:21+00:00 2026-05-29T18:40:21+00:00

I created a android widget with a icon that shows a number in the

  • 0

I created a android widget with a icon that shows a number in the right top corner in a little white circle. Now if my value is one character the value is right in the middle of the little whit circle. But when the value is 2 characters it is not right in the middle anymore.

What is try to do is if my value is more then 1 character then i want to change the left margin of the textview so the value is in the center of th white circle that is part of the icon.

I tried all ready with the

RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.widget);
updateViews.setInt(R.id.Value, "setMargins", 10);

But that gives a exception.
Is there a way of changing the left margin in a widget on runtime ???

My layout file looks like:

<ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/widget_alarm" 
        android:id="@+id/imageAlarm"
        android:layout_marginLeft="10dp" 
        android:layout_centerVertical="true"
    />

    <TextView  
        android:id="@+id/alarmCount"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:layout_marginTop="22dip"
        android:layout_marginLeft="58dip"
        android:text="0"
        android:textColor="#000000"
    />
  • 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-29T18:40:24+00:00Added an answer on May 29, 2026 at 6:40 pm

    add to your textview in xml

    android:gravity="center_vertical|center_horizontal"
    

    Your text will always be in center.

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

Sidebar

Related Questions

I created an Android app widget that displays some text. By pressing on the
I have created an App Widget for Android 1.5. It uses a TextView to
I created an Android project a few months ago and now have to automate
I created a native Android app that basically hosts a webView control. That webView
I am new to android widget.I did sample application , that want to show
When android unbind a service I created (service.MyService), I see the following DeadObjectException. Can
I created a SQLite database on Android device. The program can read/write to database
I created one application to read all the contacts stored in android 2.0 emulator.I
I have created a small and simple android app. I tried installing it on
I created a project, probably as an Android project without thinking. I then did

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.