Android tabhost: How to set the tabwidget over the tabcontent? - android

I received a design where I have a custom tabbar, and one of the tabbar's tabs is bigger than the others.
This part was easy to do, but that bigger portion of the tab was suposed be over the tabcontent object, so when the content get scrolled, that tab will be 'floating' over it.
This was what I got first:
I seted the magin_top of the tabcontent to -4dip (size of the bigger portion) and the content moved up, but it moved over the tabwidget.
This is what happened then:
I'm new to android development, so I tried to look for anything like a z-index, I found a bringToFront() and a bringToFromChild(), but I guess they were not what I was looking for.
This is what I'm trying to do:
Where the red is the content of a tab

Set the same Red background in parent container of tab-widget layout file so you can get a View like the last image.

Related

Why is my Android phone layout different then my layout on Android Studio?

The layout of my MainActivity on my phone appears very differently than the layout I see on the code editor. Images are included. I am using a TabbedView. However, the problem still exists on any layout I choose (empty/tabbed).
What can I do to solve this problem?
I am concerned about the text "Hello world" in the middle, not in the top left corner. I follow this tutorial and in the tutorial it is correctly positioned.
It works as expected, because section_label TextView width is wrap_content it changes, depending on what text it displays. And the 2nd TextViews position depends on it, so it changes too. You should be able to verify this by setting various length texts in your layout editor.
For what you want to achieve, RelativeLayout is not the best choice and you may want to use i.e. LinearLayout instead, with its orientation set to vertical and layout_gravity of second TextView set to right
This is happen because you are using the RelativeLayout in the relativelayout we can arrage our views in custom position wise by the help of give the android:id=#+id/some_id like this if you want your second view is shown just below the first view then give them the property android:layout_below="#id/view1" in your second view
Please read all the documentation of RelativeLayout form this link
https://developer.android.com/guide/topics/ui/layout/relative.html

How do I make UI elements fill the entire Android Screen

I am trying to add a bar similar to the "Today" bar here, but I cannot figure out how to force the width to match the screen. I am just using a simple textview (if there is a better way.. that's awesome, please tell it to me, but i cant find anything for it)
Here is what is happening with match_parent or fill_parent I recolored the textview to show the margins (that I dont want)
match_parent should fill the entire screen.
Check your parent activity layout or your fragment layout and you should find your margins there.
BTW, if you have a list of items like the one in the picture and you want it to have sections (like 'today', 'yesterday', etc) you should probably use recyclerview with headers instead of text view. Check this library for this, it's pretty easy:
https://github.com/cymcsg/UltimateRecyclerView

How do I make a section of an activity always-on-top?

Had a question about making part of a View Always-On-Top. Please see the Groupon picture below. The black window at the bottom where it says "From $29" & "Buy!" is always on top of the activity page. Meaning the rest of the page is scrollable above that black window at the bottom. Please note I only want this activity to have an Always-On-Top
How do I make a portion of the activity Always On Top? And what kind of layout did you think they used for Groupon? I was just going to make a RelativeLayout and layout_alignParentBottom="true".
You could probably get away with having a vertical linear layout with two children. The first one a scrollable area and the bottom a view with whatever it is you want to be 'on top'. Since there's no transparency there's no visual difference between having the black view as always-on-top and having one view on top of the other (in the y-axis, not z-axis). Plus, if you do it this way you can reach and see the bottom of the scrollable view's content.
To the best of my knowledge, the best way to do this is by implementing a BaseActivity with this View, and have all your activities extend this activity instead of the standard Activity.

Making tabs, buttons, or neither?

I'm not really sure what tools I should be using to create a desired outcome...
At the bottom of the screen I would like to have three buttons, something like what is at the bottom of this screen except only using text instead of icons, and only having three options, not four.
Is this a tab view? I don't need a tab view because I don't need the tabs to stay on screen after one is clicked.
According to the layout source for the DeskClock they are indeed image buttons in a linear layout. The main layout source shows that the buttons are 'included' with the main layout. Hopefully this source helps.

how to load part of the layout content alone

Friend's
I need help on loading the content alone in my page without going to new page when i selected the scroll menu.
**> I have an
1. header layout and
2. framelayout in another xml file have declared Listview and it
also have tabhost
**and also have gallery view for scroll menu.
3. content list in another xml file.****
when i selected the scroll menu i need to load the list content alone in that activity i suppose not to load whole header and and redeclare tabhost in next that scroll menu selected activity.
Thanks in advance.
I achieved this effect by having everything defined in a single xml file with multiple TableLayout views stacked on top of each other within a Merge view. In order to "load" a view, I change its Android:visibility tag from "gone" to "visible". Since you want your second view to not obscure the header, you can put a buffer (margin or padding) that offsets it from the top of the screen. The background color of this top TableLayout would have to be android:background="#00000000" so that the alpha channel is zero and it is transparent.
If anyone else has a more elegant approach, I would be interested to know as well, but this suites me just fine. The only downside I see is an extra large XML file.

Categories

Resources