Honeycomb actionbar and margins - android

I'm attempting to use a different "homeAsUpIndicator" graphic on the action bar, and I'm running into some margin issues with the edge of the screen and the graphic.
Using the "android:homeAsUpIndicator" attribute with a value of #drawable/my_graphic in the styles.xml for the project, I've managed to change the indicator to a custom graphic. That graphic has been designed with a 0dp left margin in mind - as in the left edge of the graphic should go all the way to the left edge of the screen. Instead, I'm getting a 6 pixel margin on both the top and the left side the image.
I've tried setting the margins and padding in my styles.xml, but either that doesn't work or I've applied it to the wrong resource. Also, I tried setting the actionbar background to a 9-patch graphic and let the standard indicator graphic (the "<" in Honeycomb 3.1) float on top of it...that didn't work either, as it just pushed the indicator graphic to the right of the fixed pixels of the background. It only overlayed the pixels that were identified as the stretch pixels in the 9-patch.
Is there a way to remove the 6-pixel padding/margin from the actionbar so the indicator graphic is flush with the left side of the screen? Any examples or leads would be greatly appreciated!
Thank you

Have you provided drawables for different screen sizes / resolutions / densities?
Though they should resize automatically.
See here for icon design of action bar :
http://developer.android.com/guide/practices/ui_guidelines/icon_design_action_bar.html
Also you can check the standard icons being used in your sdk folder and adapt yours to those:
the path is:
ANDROID_SDK/platforms/android-XX/data/res/drawable-XXX
https://stackoverflow.com/questions/8179653/where-can-i-find-standarts-icons-for-actionbar
Otherwise check also here:
How to remove the margin between the app icon and the edge of the screen on the ActionBar?
Also you could use a custom action bar:
Custom title bar without padding (Android)

Related

How can the top padding be removed from Android JetPack Compose ModalBottomSheetLayout?

I have tried for a few hours without success to remove the top padding from the Compose ModalBottomSheetLayout.
I tried debugging through the internal material classes to trace where the padding is being set and can't for the life of me work it out!
I want to add a background image which completely fills the ModalBottomSheetLayout right up to and including the rounded corners but clipped by them. Even if I remove the rounded corners (see pic) the issue remains with the extra padding above the sheetContent.
I have added an image with some background colors showing the issue. The blue bar is the top (extra unknown padding) of the bottom sheet opened at HalfExpanded state.
Another example with the rounded corners:

Margins on large devices

Many app's, including the swipe left Google Now screen have a colored background and very large margins to compensate for the small amount of data on tablets, particularly in landscape.
Are there any standard dp dimensions for these margins on particular devices?
I'm aware of the activity_horizontal_margin but it's far bigger than that.
There are Design Guidelines available for Android Application.
Baseline grids : All components align to an 8dp square baseline grid for mobile, tablet, and desktop. Iconography in toolbars align to a 4dp square baseline grid
List : A two-column, left-aligned list with a 56dp floating action button.
Detail view : A detail card with a 56dp floating action button.
For e.g.
Above link contains all information regarding your question.
Better go through it.
Thanks.

Styling Sherlock Action Bar

I'm trying to set an image as background of the Sherlock Action Bar, but even if the it's 720 x 112 px, it seems like the image doesn't stretch.
The white part is still part of the Action Bar, as the triangle is set in the correct position and the button on the right, has different margins on the top and at the bottom.
Do I need to make it a 9patch image? Not sure why it doesn't work..
I'm setting the background with a getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.topbar));
Thanks a lot in advance for the help!
Did you put your image in hdpi or mdpi? Try switching around. Ultimately, use draw-9-patch and safe yourself a lot of headache.

Preventing Pixelation of Images, indenting listViews and adding Rounded corners

I have a few issues and questions regarding some UI development on Android. Firstly look at this image:
Firstly at image A) This is a image that I insert and repeat horizontally to give the zig-zag shape at the top of the screen regardless of screensize and above that a textField with no content and a background color - But as I'm sure you can is that the two colors don't match up quite as perfectly as it should even though they both have the same hex color value (#BF0426). And secondly, you can also see some serious pixelation on that zig-zag image. How do I fix these 2 problems?
And then at image B) Here I have a simple listView. What I would like to do, is firstly indent it a bit on both sides, and round the corners of the top and bottom item. So basically I want it to look like the blue border drawn on the screenshot. (Your typical iOS listView). How do I go about doing this?
Thanks in advance for any tips!
For the image. Just out of curiosity, why wouldnt you simply extend your image to include the top pixels as well? In other words, build your repeating image such that it incorporates the pixels that you are trying to create using the empty textview. This will at least take care of the color missmatch, as the color will all be generated from the same place. In terms of the pixelation. Are you truly repeating the image, or are you spreading the image. A spreading will definitely cause what you are seeing.
For your tableview:
For the left and right indent, you can simply use the margin or padding attributes of tableview item. There are generic padding and/or margin attributes (which will pad all of the top, bottom, left and right), or there are separate padding and/or margin attributes for each top, bottom, left, and right. Here is a great link on padding versus margin that you may want to read.
Difference between a View's Padding and Margin
Example attribute (as called in an XML file) for bottom margin
android:layout_marginBottom
setMargins(left, top, right, bottom) // for setting margins programmatically
Example attribute (as called in an XML file) for top padding
android:paddingTop
setPadding(left, top, right, bottom) // for setting padding programmatically
For the custom top and bottom, you should be able to use the following tutorial
http://www.softwarepassion.com/android-series-custom-listview-items-and-adapters/
From here, you should be able to detect the item as the first and last item and set the background property (image) to a background image that has a rounded top or rounded bottom. This is how I do it on the iPhone. I have also implemented things that LOOK like tableviews but are simply vertical layouts with my own custom views that I have made to look like what you are wanting.
One thing to consider is the file format you use is going to mutate the image as you save it (lossy compression), so a .jpg with a certain color may look different than a .bmp with the same color. Make sure you author using the same application and/or export settings when trying to match up images.
Also, if you created your image with a DPI that is not compatible with the android display it can cause serious pixelation in detail areas, especially with gradients and drop shadows.

Font padding problems with Droid font in Android

I'm trying to create some 9patch images that have some text as their content. I define the stretchable area with a black pixel line top and left. And I define the content area with a black pixel line right and bottom.
However, it seems as though Droid is adding padding to the top and bottom of the content area, messing my layouts up. Has anyone else experienced this?
You say you're putting a black pixel line for the top and left? For the top, you should place just a single pixel for the stretch point. For the left, you can place either one or two pixels (two if there are two separate places you would like to stretch). Let me know if I am misunderstanding you though.

Categories

Resources