How to make Verital and Horizontal scroll on 2 layouts? - android

I am trying to make Layout that contains 2 layout, vertical and horizontal scrolls.
Like this :
http://202.131.244.11/demo/VerticalAndHorizontalScrolls.PNG
How to make it ?
I've tried it. But horizontal scroll doesn't work for me.
Please advise.

What's your layout xml look like? Presumably, you want a hierarchy like this:
ScrollView
ViewGroup (some sort of layout to contain everything)
ViewGroup (layout 1)
HorizontalScrollView
ViewGroup (layout 2)

Related

Putting a View on top of Scroll View while Scrolling down

Basically, I have a Scroll View and it contains several child inside Linear Layout. Now, I want to show a View constantly on the top of the screen when it is scrolled down.If it is scrolled up everything should be as it was earlier.
Can anyone just help me out? Any help would be appreciated! (Thanks in advance).
Define a ObservableScrollView class entends ScrollView.
Then write your layout xml like this:
<RelativeLayout>
<View/>
<ObservableScrollView>
</ObservableScrollView>
<RelativeLayout>
In ObservableScrollView class,focus on this onScrollChanged function.
Change the visibility of your target view by param 'y'.

How to add footer view in a Horizontal List View

I am using a Horizontal List View
https://github.com/MeetMe/Android-HorizontalListView
library, I need to set a footer view on it.How can i set it.
I think you didn't understood my comment. I mean something like this:
<LinearLayout with vertical orientation>
<HeaderView/>
<HorizontalListView/>
<FooterView/>
</End of LinearLayout>

Are layouts same as ViewGroups?

I'm a bit confused, when I declare a layout in XML, and I call the:
R.layout.idname
is this considered the ViewGroup?
It depends on the widget you declared inside your layout. For instance you can declare a single TextView inside your layout. TextViews are views, not ViewGroup. If you declare a LinearLayout for instance, it will be a ViewGroup. If you take a look to the documentation you can see the direct and indirect subclass of ViewGroup
is this considered the ViewGroup?
No, this is the complete layout file.
Are layouts same as ViewGroups?
No, one is the file. A ViewGroup would be any View such as a RelativeLayout, LinearLayout, etc... that holds other Views.
From the docs
A ViewGroup is a special view that can contain other views (called children.)
Not really. It depends on which xml layout you have given R.layout.idname to.
TextView, ImageView, EditText for examples are NOT viewgroups.
FrameLayout, RelativeLayout, LinearLayout etc are considered viewgroups.
A clue is in the name really... viewgroup. a view that can be a grouping of views.
No, Layouts are not same as ViewGroups. While every Layout is a ViewGroup, there are ViewGroups that aren't layouts (e.g. ViewPager, ScrollView). Regarding an XML file in R.layout, it depends on the root element of the XML: if for example it's a LinearLayout - you'll be able to cast it to ViewGroup, if it's an ImageView - it is considered a View.
View group: is a combination of views
Layouts: how views should sortup
View group has views inside it, but how the views should be arranged, the arrangement of views is known as layouts.
For examples, linear layout and relative layout are both layout and view group because they have views inside and the arrangement of views in them are known as layouts.

Is it possible to get two Viewgroup in single xml?then how?

parent as relative layout i have textview (for title) and linearlayout for viewgroup in that by id am accessing viewgroup. and inside child linear layout i have textview and relative layout for image and textview .after viewgroup in my above linear layout i want to access one viewgroup how to do that?
Did not understand what do you want to achieve, but you must remember, that layout structure in Android is a tree. Every two View Groups can have a parent View Group above them. So just instantiate a root layout and then place any number of View Groups you need there. Good luck!

How to change Nested layout's child viewgroup's width in java code?

I have a layout xml file with a linear layout. One of the children is again a ViewGroup Relative layout. In my java code i want to change the width of this child Viewgroup for my requirements. I tried this
enter code here
ViewGroup childViewGroup = (LinearLayout)findViewById(childViewGroup);
LayoutParams l = childViewGroup.getLayoutParams();
l.width = 360;
childViewGroup .setLayoutParams(l);
I couldn't do this because findViewById(childViewGroup) doesn't fetch ViewGroups it does only for Views.
Note: I cant define a whole new layout.xml for this minor requirement since it is huge layout file and might cause performance overhead. I wanted to just change the width of the child view group in my java activity code.
Thanks in advance for your help.
ViewGroup is a subclass of View so findViewById should work fine. You're casting the result to LinearLayout, is the childViewGroup a LinearLayout or RelativeLayout as you specified in the question? – codelark Oct 6 at 23:21
You may use ViewStubs.
You can find a reference here:
http://developer.android.com/resources/articles/layout-tricks-stubs.html

Categories

Resources