In my Android app I use a TabWidget without any special customization. I'd like Android to take care of the specific appearance, which works fine if you compare Android 1.6 with 2.1 for example. By just using a TabWidget the same code leads to different forms of tabs because the SDK defines how to draw it.
Here is how it looks on 2.1 for example:
So, the highlighted tab is gray and the font is white and you can read it quite well.
But, if you have HTC Sense, it looks like this:
The picture isn't that good, but just believe me that it's white text on white background which is not really that easy to read...
My questions are:
1) Why does Android create a TabWidget with white on white text? I never defined either the text color or the background color, so the system is supposed to chose sensible colors.
2) I assume that other TabWidgets look just fine on HTC Sense, because otherwise it would be quite a big and popular problem. So why is my TabWidget having this problem and not others.
3) How can I fix this problem without changing the appearance on non Sense devices?
As I said I did not customize the TabWidget in any way. Here is my definition:
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#android:color/black"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="0dp"
>
<ScrollView
android:id="#+id/shortenerScrollView"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:background="#android:color/black"
android:fadingEdge="horizontal"
>
So, besides defining black as my general background color of the app, there's no color or style defintion made. The only exception might be that I'm using standard Android ids for TabHost and TabWidget.
/Edit:
Here's the defintion of the tabs in the onCreate method:
th = getTabHost();
th.addTab(th.newTabSpec("shortener").setIndicator(getString(R.string.tabShortenerName),
res.getDrawable(R.drawable.url_zip)).setContent(R.id.shortenerScrollView));
The class extends a TabActivity.
/Edit 2:
The device that comes up with the white on white text is a HTC Legend running Android 2.1 btw.
/Edit 3:
dream3r was right. Changing the targetSdk value to 4 did the trick for me, too (before, it was set to 6)! I don't really get it, but I can live with that for now. :)
Here's a picture of how it looks now:
Do you have android:targetSdkVersion set in your AndroidManifest.xml?
I made some test using sample application and I have the same issue if I set targetSdkVersion to value greater than 4.
Related
I'm trying to use the bluejamesbond DocumentView to display a bit of justified text. I'm unable to get text to display even in the simplest of cases;
<com.bluejamesbond.text.DocumentView xmlns:ext="http://schemas.android.com/apk/res-auto"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
ext:documentView_text="test"
android:background="#android:color/background_light" />
I've tried both a light and a dark background in case the default colour is one of them and hence invisible.
I've obtained the library by adding the following to the module's build.gradle;
compile 'com.github.bluejamesbond:textjustify-android:2.1.1'
The only indication of any problem is a fidelity warning from the Android Studio preview, but running on the real device (4.4.2) gives the same lack of text in each case.
I'd initially tried the more complicated example, removing the progress bar and changing the text to just some simple inline text to get rid of other dependencies. That didn't work either, again with different backgrounds.
To rule out the possibility of something else in the layout affecting it, I've also created a new layout as follows. Again, with either a light or dark background the expected text "test" is not to be seen.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<com.bluejamesbond.text.DocumentView xmlns:ext="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
ext:documentView_text="test"
android:background="#android:color/background_dark" />
</LinearLayout>
There is a (working) demo of the library on Play Store which gives an indication that this library is of decent quality and well maintained, so how can I move on from here?
I'm sorry if this question's been asked already but I wasn't able to find any answers. Here's some background context:
I was testing my app on my Nexus 4 to fix some minor bugs. However, just as eclipse was launching it, there was a powercut in the area, switching my computer off. Eventually, once the power restored, I thought I would set a font by .setTypeFace() before running my app again but this made my app crash when I did run it. So after fiddling around with the code and finding no fix, I decided to get rid of the whole font and just run the app with the bug fix. However, this made my app look like this.
Now on eclipse, the graphical layout is showing this. My app before today was showing like the graphical layout perfectly fine. No errors are showing up on eclipse.
Why has this happened and how do I fix this? Could I have corrupted the whole file?
Thanks.
EDIT: the xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/testbg"
android:orientation="vertical"
android:weightSum="100" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="33" >
---- bunch of textviews ----
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="57" >
---- More Textviews ----
</RelativeLayout>
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="10"
android:orientation="horizontal"
android:weightSum="3" >
---- three buttons ----
</LinearLayout>
</LinearLayout>
I finally figured it out - it was the background. I must've obviously messed up the 9.png somewhere because it fixed itself once I got rid of the background.
Normally this happens with my apps when i change the font , some fonts appears like this in the layouts , some play around i use is adding a character or a dot after tab space , and it works , however double check the font issue again ,try to set the font again or to set another font.
I have a problem that sounds like this:
I have a TabHost and I want to change it's size (height and width) so I used inflate to do this
TextView tabContent = (TextView)getLayoutInflater().inflate(R.layout.tab_content,tab.getTabWidget(),false);
and my xml:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/tab_label"
android:layout_width="80dp"
android:layout_height="fill_parent"
android:gravity="center"
android:textSize="14sp"
android:background="#color/green"
/>
This is working, but the problem is:
How do I inherit the old style of the tab since this is canceling it.
I mean i want this to be on the grey background and if i click it, to take focus and be yellow and so on, like the default tabs?
Thanks
Arkde
When you coose to customize your tabs, the standard tab behaviour is not accessible anymore.
Here is a very good example about customizing Tabs:
http://joshclemm.com/blog/?p=136
I have the following layout:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#EAEAEA">
<ListView
android:id="#+id/xxx"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="#464C59"
android:divider="#A4C539"
android:dividerHeight="1px">
</ListView>
<ImageView
android:id="#+id/home_bottom_bar"
android:src="#drawable/bottombar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:clickable="true"/>
</FrameLayout>
The goal is to have some sort of advertising bar at the bottom of the activity (which contains a list of items). It works ok, except for one thing! There is some sort of extra space just under the bar (it's very small but it's noticeable enough). By the way, all the paddings are set to 0 so where does this space come from?
Thanks!
EDIT
After investigating the issue, it turns out that the custom background (#EAEAEA) is causing this extra space. Still don't know how to fix this though.
When you mention that it is a small extra space, it may be the tiny gradient at the top and bottom. Created by ListView, when it is made scrollable.
You may read about ListView Backgrounds, this should give you the idea on how to fix it, if it is caused by this special gradient.
This gradient line can apparently also be removed: extra line in tab host
You may want to use the merge tag since every activitys base layout is a FrameLayout.
(This may cause the padding. Im not 100% sure on this one though)
Look here.
My first (old) Android app (Suspension Calculator) is showing a problem I cannot find a solution for: the spinner control on some spinners is showing transparent lines in unwanted places. The pattern is this: every other spinner is having this problem, starting with the first spinner control. So while spinners 2, 4, 6, ... have no unwanted lines, spinners 1, 3, 5, ... have them.
The following image (link below) shows the spinner in selected state first, and in unselected state after the red separator. In selected state, the transparent line is at baseline height for the entire control except some places where the button text can be. It's a little different in unselected state.
I cannot provide an image directly:
[...] as a spam prevention mechanism, new
users aren't allowed to post images.
But I can give you a link:
Screenshot that illustrated the graphical spinner problem
The XML file under res/layout looks like this:
<ScrollView ...>
<TableLayout ...>
<TableRow>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/units"
android:gravity="center_vertical"
android:paddingRight="5dp"
/>
<Spinner
android:id="#+id/unit_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"
/>
</TableRow>
...
</TableLayout>
</ScrollView>
I see this problem at least since Froyo (Android 2.2). In earlier versions (at least Android 1.6), it wasn't there. It's not there in the Graphical Layout editor in Eclipse, but I see it running the application on the phone and in the emulator - that's at least consistent and hints to a problem I'm causing by not doing things right ;-).
Actually I can reproduce this behavior on Android 2.3. Not possible on Android 2.2 and lower.
It' doesn't matter if you place the Spinner in a TableLayout or RelativeLayout. Same problem there..
Only solution to get ride of the lines was to put a 1px-View between the spinner:
<Spinner android:layout_height="wrap_content" android:id="#+id/spinnerDriver"
android:layout_width="match_parent" android:layout_below="#id/driverDesc" />
<View android:id="#+id/helper" android:layout_height="1px"
android:layout_width="match_parent" android:layout_below="#id/spinnerDriver" />
<Spinner android:layout_height="wrap_content" android:id="#+id/spinnerDriver1"
android:layout_width="match_parent" android:layout_below="#id/helper" />
This is actually a very, very, very... ugly solution but it works for me...