Is the android:divider attribute under the TabWidget working? I tried the Tab Layout tutorial from android just to test (http://developer.android.com/resources/tutorials/views/hello-tabwidget.html) and set the android:divider to some image (for now I used the android vertical scrollbar as the drawable to really emphasize if its getting picked up (copied it from frameworks), but when I ran it on the emulator, it doesn't appear to be working. According to the docs, the TabWidget does seem to support this attribute: "Drawable used to draw the divider between tabs."
Can anyone help? I am using a nine-patched drawable as my divider image drawable.
MB
It doesn't look like the divider attribute is available anymore for TabWidget. One way to add a custom divider is to set it programmatically:
mTabHost.getTabWidget().setDividerDrawable(R.drawable.divider_vertical_dark);
Make sure however, you call this before you set the content of the tabs. It would crash on me if I called it after.
I had the problem in ICS, where divider was visible. None of the solutions worked except for the following.
<TabWidget
android:id="#android:id/tabs"
android:layout_width="match_parent"
android:layout_height="60dp"
android:gravity="bottom"
android:layout_alignParentBottom="true"
android:fadingEdge="none"
android:showDividers="none" >
</TabWidget>
Key line was android:showDividers="none"
I had this issue and solved it with the following code
tabHost1.getTabWidget().setDividerDrawable(R.drawable.example1);
if(Build.VERSION.SDK_INT >= 11)
tabHost1.getTabWidget().setShowDividers(TabWidget.SHOW_DIVIDER_MIDDLE);
For api levels below 11, it worked with the first line. For 11 and higher I included this to get this working. setShowDividers is added in linearlayout from api level 11. Hope this helps someone
Having the same issue myself. I only see the problem in Ice Cream Sandwich (ICS / 4.0.x). In android 1.6 - 2.3.4 there is no issue, dividers show up properly when setting a drawable in code, or in the xml layout.
I've tried just about everything I can think of to fix it but nothing works, including Josh's answer above :( though I have noticed that when setting any drawable as the divider, it will take up the space between tabs as if there was a drawable there, but it's just not visible.
Hopefully that gives someone else a hint as to what could be happening..?
I removed divider line from tabbar with use of below magical lines.
mTabHost.getTabWidget().setDividerDrawable(null);
OR
mTabHost.getTabWidget().setDividerDrawable(R.Color.transperant);
Related
I know there are many topics discussing tint functionality prior to sdk 21, but
they either use some kind of imageviews (which I dont) or solve it programmatically (which I dont want to).
My case:
I have a constraint layout with a 9-patch drawable as background:
<android.support.constraint.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/testDrawable">
This is my drawable:
<nine-patch xmlns:android="http://schemas.android.com/apk/res/android"
android:src="#drawable/ninepatchdrawable"
android:tint="#color/lightBlue"
android:tintMode="multiply" />
This works fine for updated devices, but as I said the tint isn't working for devices sdk < 21. I don't get any kind of error message either.
I already tried changing my layout to:
<android.support.constraint.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/testDrawable"
android:backgroundTint="#color/lightBlue"
android:backgroundTintMode="multiply">
or using app:backgroundTint as suggestet in another question.
Thanks in advance
You can try something like this:
ImageView.getDrawable().setColorFilter(new PorterDuffColorFilter(context.getResources().getColor(**color**), PorterDuff.Mode.SRC_IN));
Don't believe it'll work with a lower API -> but its a good way to change tint on the fly
There is an obvious reason why.
If you check the docs. The first part of the first line is:
With Android 5.0 (API level 21) and above,
Because android:tint was added with material design in API 21. And because it was added in API 21, it is a tag that has no meaning on API 20 and lower.
Using the support library (appcompat library) should allow you to use it. You need to add another namespace, but that isn't the biggest job to do. You can also do it in styles.xml
And backgroundTint is something completely different as you can see in this question
I have an android app that has been working fine pre-Android 5.0. With the update, I noticed that checkboxes and radiobuttons placed on white backgrounds are not visible if they are not selected. For example, this is what a checkbox looks selected and unselected in jellybean:
As you can see, there is a light gray square when the checkbox is not selected. However, after updating to lollipop, this is what it looks like:
So, as you can see, there is no gray square or anything that suggests there is a checkbox here. The same problem happens with radiobuttons. I really don't want to go trough the pain of creating new drawables just for this simple ting. I have seen that checkboxes within the accessibility menu of android 5 have a nice square, but haven't figured out how to make mine look the same:
I tried creating a new android project and just adding some checkboxes and radio buttons with a white background, but they are still invisible when unchecked. I'm using xamarin studio and c#, if that makes any difference. Anyway, I'll understand any java code you post.
This is what my checkbox code looks like:
<CheckBox
android:layout_width="wrap_content"
android:layout_height="0dp"
android:id="#+id/chkSeleccionar"
android:layout_gravity="right"
android:gravity="center_vertical"
android:clickable="false"
android:focusable="false"
android:scaleX="1.5"
android:scaleY="1.3"
android:layout_weight="50"
/>
I couldn't get the theme working, but what did work for me was the following:
android:button="#drawable/abc_btn_check_material"
android:buttonTint="#color/red"
Put this into your CheckBox XML layout.
Just change the
android:buttonTint="YOUR COLOR"
It works.
Make sure you are using a Material theme for Android 5.0 devices - this will ensure you're styling remains consistent with other components. Look for an android:theme element in your AndroidManifest.xml file (either on your application or on an individual activity), then look up what style is set there and check the parent attribute for the style.
Add this attribute
android:buttonTint="#EEEEEE"
I have added a scrollView and if deploy on the android tablet,it has some problems. But it works fine on cellphone.
When users move to the top or bottom of the whole page,it will automatically show the blue shadow which indicates users reaching the bottom of the page.
I want to remove those indicator since it affects the UI.
Is there any way to remove or set in the XML?
I have tried different parameter to set on the scrollview but it doesn't work.
Please help.
fadingEdge is deprecated. Use this in your ScrollView: android:overScrollMode="never"
Add this extra line to your ScrollView definition:
android:overScrollMode="never"
or add this to your code:
findViewById(R.id.sobreScrollView).setOverScrollMode(ScrollView.OVER_SCROLL_NEVER);
Try this:
android:overScrollMode="never"
Add this to the scrollView
android:fadingEdge="none"
Pre API level 14:
android:fadingEdge="none"
API level 14+:
android:requiresFadingEdge="none"
See this:
https://developer.android.com/reference/android/R.attr.html#fadingEdge
This attribute is deprecated and will be ignored as of API level 14 (ICE_CREAM_SANDWICH). Using fading edges may introduce noticeable performance degradations and should be used only when required by the application's visual design. To request fading edges with API level 14 and above, use the android:requiresFadingEdge attribute instead.
setOverScrollMode(View.OVER_SCROLL_NEVER)
As mentioned by Romain Piel on this post: https://stackoverflow.com/a/7106752/956975, Pim Reijersen pointed out in the comments that android:fadingEdge is deprecated and will be ignored as of API level 14.
Remove the shadow on a ListView/GridView/ScrollView like so
in XML:
android:fadingEdgeLength="0dp"
in Java:
view.setFadingEdgeLength(0);
I've come across a bit of a weird issue with activities using the Holo Dialog theme (#android:style/Theme.Holo.Dialog) in Ice Cream Sandwich.
It seems like they ignore their layouts and fill the entire screen instead of the layout width and height from their XML layouts. The same layouts are working as expecting in Honeycomb, but not on Ice Cream Sandwich.
Example:
The correct way (Honeycomb)
The incorrect way (Ice Cream Sandwich)
Both devices are running the exact same version of the application, and are using the exact same layout. Here's the layout in question:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout1"
android:layout_width="940dp"
android:layout_height="600dp"
android:layout_margin="10dp" >
<GridView
android:id="#+id/gridView1"
android:layout_width="940dp"
android:layout_height="600dp"
android:horizontalSpacing="10dp"
android:numColumns="3"
android:smoothScrollbar="true"
android:stretchMode="columnWidth"
android:verticalSpacing="10dp" >
</GridView>
</LinearLayout>
Any ideas to how this can be solved? A similar issue occurs on my ICS-based Galaxy Nexus, which completely ignore the match_parent tag for height and width. Is the dialog theme broken in ICS?
Update:
I've done some more testing, and it seems like 894dp of width or less will produce the "correct" look, but if I set the width to 895dp or more, it'll be the incorrect look. The emulator's acting the same way. This is extremely weird...
I don't think it is true that ICS discourages dialogs. Indeed, they have a whole page at Android Design. What is true is that DialogFragment (which is even provided in the Android Support library) is preferred over the legacy Dialog.
I corroborate your observation about the dialog popping to full-screen, but the behavior is device-dependent. On my Xoom tablet it happens at 915dp, not 895. On my Galaxy Nexus, it happens at 444dp. And on my Galaxy Tab 10.1, it does not happen at all.
If you dig into the source, you can see that there is a Dialog theme that is descended from Holo for smaller screens and from Holo.Dialog.FixedSize for larger ones. I would have expected this to be based on display size, not layout size, but perhaps I would be mistaken. I'll try to figure out what causes the jump.
I couldn't find an answer for this myself, so I eventually dropped the dialog theme and instead used a full-width standard theme layout. I think ICS discourages the use of dialogs, so maybe that's why it's changed.
All version of Android ignore the width/height of a Dialog themed layout xml.
To fix this, after calling:
setContentView(R.layout.contacts_preferences);
add a line:
getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
or WRAP_CONTENT for your needs.
Try swapping your LinearLayout for a RelativeLayout. That will do the trick :)
Somehow LinearLayouts always fills the screen when displayed in a dialog. RelativeLayouts don't.
I have a fixed height ListView. It has divider between list items, but it also displays dividers after the last list item.
Is there a way to not display a divider after the last item in ListView?
Just add
android:footerDividersEnabled="false"
to your ListView description
As #ScootrNova said, this seems to be behaving differently (a.k.a buggy) in android 4.4.x (I don't know exactly when the problem is introduced)
This is related to the specific case of using using padding + clipToPadding="false" - in 4.4.x the footer is drawn outside of the view but clips to padding reveals it.
The solution I used was to set the footer over-scroll (android:overScrollFooter) to transparent which somehow works...
My final solution (note that android:footerDividersEnabled is kept for back-compatibility):
<ListView
android:id="#android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="#dimen/activity_horizontal_margin"
android:divider="#color/divider"
android:dividerHeight="1px"
android:clipToPadding="false"
android:scrollbarStyle="outsideInset"
android:overScrollFooter="#android:color/transparent"
android:footerDividersEnabled="false"
/>
tested on a HTC One X running 4.1.1, a Nexus 5 running 4.4.4 and a Samsung Galaxy S5 running 4.4.2 (thanks to #Dallas187). Seems to be working Lollipop too. (thanks to commenters!)
If you want to do this by code it's:
listView.setFooterDividersEnabled(false);
and if you're using a ListFragment you can get the listview by:
listFragment.getListView().setFooterDividersEnabled(false);
Only commented because this comes up as #1 in google
It seems below line does not work on lollypop device.
listView.setFooterDividersEnabled(false);
So need to use this below code to remove divider after last item in the list.
listView.setOverscrollFooter(new ColorDrawable(Color.TRANSPARENT));
Use background = #android:color/transparent. Works perfectly. You can still use the background of your row layout