Android :: Auto-centering And Auto-clipping TextView Background
Apr 4, 2010
Is there a way to tell Android to do the following when setting the background image for a TextView?
1. Scale the image so that it's just large enough to fill the the entire viewing area without any black borders, while still maintaining its aspect ratio. This might require clipping once the image is actually displayed, but that's OK (read on).
2. Then, center the image in the viewing area, both horizontally and vertically.
3. Finally, clip the image to the size of the viewing area, without any further rescaling.
I'm guessing that this kind of image processing is not automatically done via any of Android's facilities, and that I'll have to do it myself. If this is a correct assumption, could someone point me to some documentation or some examples which could explain how I can accomplish this? I'm guessing that I'll have to subclass my TextView and implement my own onDraw() method, but could someone confirm or deny that assumption?
I'm trying to limit my mobile data usage with out jumping through hoops.
I'm looking for a widget, that with one click of a button, it can restrict background data, disable auto-sync and enable mobile data, and when pressed again, enable WiFi, disable background restriction and enable auto-sync.
This function, no matter how trivial, would save time and effort.
Is there anything like this out there? Would something like this require root?
I have a TextView in my android application that has a set width on it. It's currently got a gravity of "center_horitonzal" and a set textSize (9sp). I pull values to put on this label from a sqlite database, and some of the values are too large to fit in the TextView at the current textSize.
Is there a way to detect that the text inside a TextView is going to be clipped? I'd like to detect this, and lower the font until it fits. There is a nice property in the iPhone UILabel that handles this called "adjustToFit" (which also has a minimum font size), and I'm basically trying to emulate that.
Here's an example of the TextView that I'm working with:
I'm looking for an alarm clock app with one very specific feature - allow me to set the alarm tone to automatically stop after X seconds, then start again at the next snooze interval, and play for another X seconds.
Sure it seems every alarm app out there allows me to set Snooze intervals and stuff, but with my waking up habit, I don't like to physically have to touch the phone to get it to shut up until the next snooze interval. I like to lay in bed and let the alarm go for like 3-4 snooze intervals before I finally wake up.
I've tried Alarm Clock PlusV2, Alarm Clock Xtreme, Quick Alarm. None of them seem to have this.
I installed it on my Droid and when I open the list and long press on an app it gives me the option to Auto-Kill. I assume this means I won't have to kill this app any longer so I select this option but I find that I keep having to kill the same apps over and over again. What's the point of Auto-Kill or what am I doing wrong? There are lots of programs (most I didn't even install) that run all the time and I'm having battery issues so I don't have battery to waste on programs I'm not using and will probably never use.
I have a Motorola Milestone running Android 2.1.Is there a widget which turns "background data" ("Settings -> account & sync -> background data") on/off? I know there are several widgets which turn auto sync on off (e.g. the power control widget) and disable data connections altogether (apndroid, quick settings, etc), but that's not what I need. I searched the market, google and this forum but couldn't find anything.The only workaround I found was to create a shortcut to "account & sync" using "any cut". Not a widget, but close enough.Is there a widget, or a better way to do this?
I want to develop an application that disable the Background Data (new feature in Android 1.5) and Auto Sync and then enable GPRS/EDGE connection and vice versa.
I figured out how to enable/disable GPRS/EDGE by changing the APN settings. (weird solution. However; Android developers couldn't think a user may want to disable GPRS/EDGE) But, I couldn't find a way to enable/disable Auto Sync and Background data.
I investigated the Android code and as I understood, the Sync operation is an intend. So, I wanted to reach with putExtra to the intend and trigger the enabling/disabling. But; I couldn't find the correct keyword.
Are these the same? I have searched the forum, and can't seem to find the answer. I don't find any "auto brightness" setting in the settings menu on the Hero. I have auto backlight unchecked. What exactly does this do? Is this the screen dimming? Sorry, I am confused. Uh oh! Must be a senior moment!
While I am showing off photos I have on my phone, the screen dims...how do I keep this from happening?
Also, relating to photos..when I go to "Albums", I have 4 folders listed...Camera Shots, All Photos, etc. When I take a pictures with the phone camera, they seems to be in both folders. Why?
if i turn them both off will my email update every hour like i have it set? Or do i have to turn on one of them? I also noticed that in order to go to the market place i have to have background data on, why is this even though i can go onto the internet with both of the settings off?
My wife and I have been having the same problem. We keep the auto-brightness option checked, but every so often we find that it goes back to manual mode--and it always reverts the phone back to full brightness setting. Any ideas why this would happen?
Android:layout_gravity="center" doesn't seem to work the same in a RelativeLayout as it does in a linear one - I would just like both an ImageButton and a TextView to be centered in a relative layout - is there a basic xml code for this?
I've set my Friendstream to update every hour, and this was working fine for weeks. Recently, although it's still refreshing the sync time icon at the bottom every hour, it's not actually updating the widget with the new information. It takes a manual sync for it to refresh. Auto-sync is on, background data is enabled.
I was wondering what does this change and how (other than better battery life...supposedly) will this affect my phone? Will it continue to work the same as before? or will it only work in sprint network with no roaming or what?
So one of the cool things about Froyo is being able to check off Enable Automatic Update for market apps. So i have that checked off for like 80+% of my 80+ apps (that took a while to do let me tell you). Now i have had three apps have updates available since i checked off the box, yet they never actually automatically updated. I waited, hours, still never updated. Is there a setting i need to modify? Do i need to tell it what time of day to do it? Anyone else noticing this? I only really want it in apps that i don't care about reading the new features. But it is annoying that i have it enabled and it does nothing.
If "always on mobile data" is disabled, will this have any affect on programs that are set to auto sync with back ground data enabled(Face book, twitter etc)? I'm trying to work it out but lots of people say different things?
I have a TextView that I created in the main.xml. In my app.java I am dynamically positioning that TextView based on where the user taps the screen. The problem I am having is that when I call myTextView.setPadding(100,100,0,0), it moves the actual Text of the TextView, but does not move the Colored Background of the TextView.
I'm attempting to change the background color of an Android TextView widget when the user touches it. I've created a selector for that purpose, which is stored in res/color/selector.xml and roughly looks like that:
The clickable attribute of the TextView is "true", in case that's of interest.
When I assign this selector to a TextView as android:background="@color/selector",
I'm getting the following exception at runtime: ERROR/AndroidRuntime(13130): Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #6: <item> tag requires a 'drawable' attribute or child tag defining a drawable
When I change the attribute to drawable, it works, but the result is looking completely wrong because the IDs appear to be interpreted as image references instead of color references (as the "drawable" suggests).
What confuses me is that I can set a color reference, e.g. "@color/black", as the background attribute directly. This is working as expected. Using selectors doesn't work.
I can also use the selector as the textColor without problems.
What's the correct way to apply a background-color-selector to a TextView in Android?
I am having a friend from another country, so i'm using a Websms app with fishtext connector. I would like to know if there exists any app that automaticaly turns internet connection (wifi or mobile connection) on whenever a certain app is active and then turns off when screen is off? Or simply an app that turns wifi/mobile network on/off when the screen is on/off ? on my oold phone it turned on internet connection itself when sending data, then turns off when done! so simple and smart...
I want to add an auto update function to an app. This app can download a new version of itself, i.e., a new apk file. After finishing downloading this apk file, how to let the app update?
I'm going to try this by using PackageManager.installPackage(), but failed. The system said no one has the permission to install a package, even I had added "<uses-permission android:name="android.permission.INSTALL_PACKAGES" />" to the manifest.xml.
I have a situation where I am using a TextView with an image and would like to set a background on just the text part. When I use android:background it sets the background behind both the text and the image. Is there a way to have it just put the background behind the text without me having to tear apart my layout and use a separate ImageView with the TextView?
But I want this to do from code rather than Xml.I have done everything that I have done in Xml like font,width,Height,font dynamically through code , but not able to set Background that I mentioned in Xml file . How can we set content of Xml file as background to textview similar to how we set background as XML in main.xml.
In the code I have done like this: t1=new TextView(this); t1.setText(ed1.getText()); t1.setHeight(25); t1.setWidth(60); t1.setTextSize(10); But I didn't find how to set background i.e. how to set XML content as background?