Using TabWidget.setDividerDrawable()? - android

Has anyone had any success with TabWidget.setDivider()? I'm not sure it does what I'm assuming: gives you a chance to supply a drawable to be drawn between each tab instance?
mTabHost.getTabWidget().setDividerDrawable(R.drawable.dividerDrawable);
this does not appear to do anything. Looking at the tab drawable resources in the android project shows that the dividers are actually drawn into the tab images themselves - is this supposed to work or is it not supported?

Call that before you set the content of the tabs.Or It would crash.
similar answer is here

Related

AndroidStudio Adding an image to draw with srcCompat

I am trying to do a drawer activity with Android Studio and I'm wanting to personalize the icons used. I've downloaded the icons I want to use and for the most part, it's okay.
In fact, I can modify all the android:icon icons but I have no idea how to modify the app:srcCompat icons. I don't know how to detect the image I want to use in this case...
Do you know how I can do it? Could you explain this to me?
Thanks a lot!
Edit: The file I'm working on as a base is the generated project with Drawer activity as the main activity. For example, if I wanted to modify the icon in the nav_header_main.xml file, how could I do to have my image (.png) transformed in a way detected by Android Studio as compatible with srcCompat
Ensure your image file is in res/drawable folder(or drawable-xhdpi/xxhdpi, determined by your design)
Refer it by app:srcCompact="#drawable/$IMAGE_FILE_NAME" in your xml.
Then you should see what you want.
Please check the doc to further understand the official usage.
Well... I was blind! I was wondering how I could add my icons but they were, I was just mistaking on the address... #android:drawable/... is obviously not #drawable/... but I didn't notice. So be aware that there is a difference and it'll be okay I think!

Is there a quick and easy way to preview a layout at different screen sizes?

Is there a quick and easy way to see how my application will look on different screen sizes and shapes? Currently, I'm going into the AVD manager, editing my device definition, and then launching a fresh emulator. It takes maybe ten minutes for each one.
They layout is defined entirely from resource files. I don't actually need to execute the app. Is there a faster way to do this?
Edit: I should add: there are some custom widgets in the app.
While looking at a layout open the "Design" tab or open the "Preview" tab on the side. On the top of the window you will see a list where you can change the layout and orientation.
May not solve your entire issue, but it's a good to know.
If you want to have a preview of a static page (not rendered at runtime, like recyclerview), you could use android studio to do that.

Android: Locating basic drawable

How do you reference the drawable for the 'home as up' icon?
I am trying to add this drawable in a custom XML layout. I do not want to change the icon displayed in the ActionBar, but rather use the drawable for something completely different
Tips on how to go about finding it without searching through every item are appreciated!
This image is named as ic_ab_back_holo_dark_am.png
or ic_ab_back_holo_light_am.png
These images are at sdk/platforms/version/data/res/drawable-versions where version must be 11 or later.
like
sdk/platforms/android-19/data/res/drawable-hdpi. You can find all images from there with there actual name.

Suggestions for android layout

I currently got this complex screen to implement the XML code.
I suppose to build with the tablelayout, but i still have no idea how to place the item on the shelf and the wooden background behind that. Could anyone hint me some ways ? Thanks
Set the bitmap as your activity's background drawable. From there, you've got several possibilities. Two that should work are
1) Place transparent Button's on the activity, using an AbsoluteLayout.
2) A couple of people have coded solutions similar to the HTML image map construct, and posted them in public fora. Google "imagemap android" and borrow.

Android ListView being replaced by a drawable or showing incorrect background

I am seeing some very weird behavior with a set of ListViews that I have in a single Activity.
I have 5 ListViews that make up a custom control that acts like a lock combination on a briefcase. All 5 of these have transparent backgrounds and they are overlaid on top of their background using a RelativeLayout.
Every once and a while, all 5 of the ListView backgrounds will be filled with a drawable png image that I have on the same Activity. When this image shows up, there are no elements in the ListViews like their should be. I usually clean the project and push it back onto the phone which fixes the problem. However, I am trying to figure out if the issue will happen whether or not it worked out of the box.
I am not sure if the ListView is being entirely replaced by the drawable. I DO know that there are never any elements in the ListViews when the issue occurs.
What would cause the issue of an image resource showing up as the ListView, instead of the ListView and their contents?
Update:
I thought this could be resolved by cleaning/rebuilding the project, however I'm now finding out that this problem occurs during run-time.
After replace an image on the home screen, I found that the image being incorrectly loaded into the ListView is actually from another Activity.
If I used my own transparent #00000000 color for the android:divider of the ListView, I would see this issue.
The fix was to use #android:color/transparent instead, and the behavior corrected itself.
If the image is the background of a parent element in your layout XML, then it will show up when your lists are empty.
Alternatively, does your ListView specify an empty image to be displayed when there are no elements in the list?

Categories

Resources