Android Question Scaling problems

DaveW

Active Member
Licensed User
Longtime User
I am having problems with scaling and positioning views on a TabHost. I put a Tabhost and one button on the main layout and 2 more buttons on another layout that is called as the contents of the Tabhost's first tab. The buttons are in the top left and bottom right corners, positions set by anchors (all 1 unit in from the edge). As you can see from the screenshots, the red button, top-left is correctly positioned as you would expect. However the Green and grey buttons bottom-right are not. The grey button is on the main layout and is closer to the corner than the green button (on the tab layout) but neither is the 1 unit in from the edge as the red button is.

The difference in alignment is also different for the 2 screens I tested the app on. One has 'Nexus' style on-screen controls, the other does not. The difference in position is very noticeable.

Does anyone know why this is happening - and more importantly, how I can get the buttons or other views to be correctly positioned relative to the bottom and right edges?

The bare-bones project is also attached as a zip file.

Screenshot_2016-10-02-14-16-29x1.png Screenshot_2016-10-02-14-17-35y.png
 

Attachments

  • Scaling Test.zip
    211.8 KB · Views: 162

fixit30

Active Member
Licensed User
Longtime User
From experience, the TabHost has some default padding which causes this. You can use the TabHostExtras library to remove this padding.
 
Upvote 0

DaveW

Active Member
Licensed User
Longtime User
Hmmmm, Sorry Fixit, but I think I spoke too soon. I have been playing with setTabHostPadding and setTabContentViewPadding and it's all set to zero. Positive values pull the edges in but negative values don't seem to have any effect. And anyway, the grey button is not on the Tabhost, it is on the main activity.
 
Upvote 0

DaveW

Active Member
Licensed User
Longtime User
Hi Erel,

Thank you for the suggestion. I had hoped that there was a better alternative to TabHost but had been unable to find it yesterday.
 
Upvote 0
Top