Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Activity content overlapping TabView

 
Astha Sharma
Ranch Hand
Posts: 250
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I want to make an app with TabView. TabView contains 3 activities. My Activity layout is a ScrollView and overlapping the tabs at bottom. I am attaching the image of screen with tab.

Here is my xml file for TabView-

This is my xml file for activity contents-
error.png
[Thumbnail for error.png]
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have the Tabs and the Tab Content in the same FrameLayout, so when you put the content in, the tabs get covered. The TabWidget should go outside the FrameLayout and inside the LinearLayout, as it is not part of the tabcontent.
 
Astha Sharma
Ranch Hand
Posts: 250
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve Luke wrote:You have the Tabs and the Tab Content in the same FrameLayout, so when you put the content in, the tabs get covered. The TabWidget should go outside the FrameLayout and inside the LinearLayout, as it is not part of the tabcontent.

I tried this but now the tab is not visible.
 
Swastik Dey
Rancher
Posts: 1604
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try putting bottom margin for the layout that appears on top of the tab widgets, and the margin height should be >= height of tab.
 
Astha Sharma
Ranch Hand
Posts: 250
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried putting bottom margin in scroll view. It worked. Thanks
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The margin trick works, but is a bit fragile, since you are relying on the height of the other component. It isn't 'the right way' to do it. The problem is that your frame layout uses a 'fill_parent' height. If the frame fills the parent, where is the room for the tabs? Instead, you should make the tabs 'wrap_content' like they are, and not specify a height for the frame layout: instead, give them a height of 0dp, and a weight of 1 (which means it will get 1 'unit' of leftover layout space: since it is the only component needing leftover space it gets it all):
 
Astha Sharma
Ranch Hand
Posts: 250
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It worked perfectly Steve
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic