I need to have
ListView - with 3 options
Button
ListView - with 2 options
ListView - with 2 options
as what is displayed on my screen in that order, each underneath and seperate to each other. This will be too large to display on the screen to want a scrollview to encircle it all which people say you should NEVER do.
I dont want my ListViews to be scrollable as I want all the options displayed so how can I do this?
You should never nest scrollable views. Thats right. For your problem replace your ListView with Layouts, there is no reason to use ListViews for what you want to do. The layout should look like this in some way:
<ScrollView>
<LinearLayout>
<!-- your 3 options -->
<!-- your button -->
<!-- your two options -->
<!-- your second two options -->
</LinearLayout>
</ScrollView>
Related
I am developing application which requires many (more than 80) screen layouts (each layout having different image views, buttons, textviews and so on) and I have to be able to switch between them (upon button clicks). I am also using SlidingMenu so I would very much like to have only one Activity (I am currently using ActionBarActivity and the SlidingMenu serves as expandable navigation TreeView).
So my question is, what is the best practice to be able to switch between a lot of unique screen layouts within one activity ?
I suggest two ways:
1) Use FrameLayout, and Fragment
2) Use ViewFlipper in main.xml that in this one every child of ViewFliper is one of your 80 views like:
<ViewFlipper ...>
<!-- first view -->
<LinearLayout ...>
</LinearLayout>
<!-- second view -->
<LinearLayout ...>
</LinearLayout>
<!-- third view -->
<LinearLayout ...>
</LinearLayout>
<!-- and so on -->
</ViewFlipper>
Of course you can create 80 separate xml files and include them in ViewFlipper.
I have a fragment containing several layout that I want to move the focus between. The app is operated with a remote containing a D-Pad (up,down,left,right & enter).
Both "view groups" are wrapped in a FrameLayout because the second one i overlapping the first one which is stretching the whole page. The views layout looks like this:
<FrameLayout android:id="contentSurfaceWrapper">
<HorizontalScrollView android:id="contentSurfaceScroll">
<LinearLayout android:id="contentSurface">
<!-- This layout is populated with child layouts (LinearLayout) programmatically -->
<!-- Those layouts are: clickable, focusable & focusableInTouchMode -->
</LinearLayout>
</HorizontalScrollView>
</FrameLayout>
<FrameLayout android:id="navButtonsWrapper">
<ScrollView android:id="navButtonsScroll">
<LinearLayout android:id="navButtons">
<!-- This layout is populated with child layouts (LinearLayout) programmatically -->
</LinearLayout>
</ScrollView>
</FrameLayout>
Image of how it looks:
I'm able to navigate to the view: contentSurface and between all its childs with the remote from the action bar in the top of the app. But, now I want to navigate from the first view (contentSurface) and its childs to the second view (navButtons) and its childs. But I doesn't seem to be able to move the focus some how. I want the focus to be moved when reaching bottom in the first layout and back when reaching top in the second layout.
I've tried to make the children in the second layout also clickable, focusable and focusableInTouch but it doesn't seem to work.
So.. I solved it this way:
For the first child in both views, which I append programmatically, I'm setting an ID.
This ID is then used with android:setNextFocusDownId on the items in last row in top layout and in android:setNextFocusUpId on items in bottom layout on first row.
This way I can switch focus in between the childs in both views.
More info about android:setNextFocusUpId etc.
http://developer.android.com/reference/android/view/View.html
Hi I have a linearlayout and it seems that when I add a second viewflipper that holds two imageviews the second viewflipper is shown on the display screen very tiny. How do I get the linearlayout to allow me to add more views meaning even if I run out of linearlayout space I can just scroll and the linearlayout will show at the normal size.
For example when you go to a website on your phone you can scroll through the website until you reach the end of the page. I would like the same thing to work for my linearlayout.
Scrollview doesn't work/it only works for one child view.
Any ideas?
What is the problem having one child layout? How about this? ScrollView has just one child and doesn't care home many children its child has.
<ScrollView>
<LinearLayout> <!-- parent -->
<LinearLayout></LinearLayout> <!-- child 1 -->
<LinearLayout></LinearLayout> <!-- child 2 -->
<RelativeLayout></RelativeLayout> <!-- child 3 -->
</LinearLayout>
</ScrollView>
I am designer, not a programmer so I will make it clear using graphics.
I have 2 activities that I want to have as one. When user clicks on each button, a new activity is being active (normally a new window would open). I want to have all the information (text, images) on one screen that will scroll down, like in this animation.
before click
after click
You're looking for ExpandableListView. It's exactly what you want. A scrollable list that has items that can be expanded.
Assuming a LinearLayout that looks like
<LinearLayout>
<TextView/> <!-- Title, e.g. "Heating Program" -->
<TextView/> <!-- Details, e.g. "Standby mode" -->
<TextView/> <!-- Title -->
<TextView/> <!-- Details -->
<!-- etc -->
</LinearLayout>
If you set android:animateLayoutChanges="true" for the LinearLayout and then set detailsView.setVisibility(View.VISIBLE) or detailsView.setVisibility(View.GONE) from OnClickListener (each title hiding/showing its detail) you will get about that effect. But it's not perfect.
Note: Requires Honeycomb or above. Animation can be customized via setLayoutTransition(LayoutTransition transition)
I would make a custom Layout class that has all the Views in it (the main "Heating Program" view, arrow ImageView, and the details view), and give that class the knowledge of being "expanded" or not. Then when the main view/arrow view are clicked, toggle the expanded-ness, change the arrow image, and set the visibility of the details view (like #zapl says).
Example: http://cdn3.staztic.com/screenshots/cfo-magazine-mobile-1-2.jpg
I've just started learning how to program android apps, and I'm not sure how to go about it. Are they using tab layouts for both the main menu and the submenu right below it? If you could point me in the right direction, it'd be greatly appreciated.
The top menu is a TabHost.
The "submenu" looks like a HorizontalScrollView with Buttons.
The main view is a ListView.
I'd create a LinearLayout to act as the tab content's view something like this...
<LinearLayout>
<!-- Usual width/height attributes and set the orientation as vertical -->
<LinearLayout>
<!-- Usual width/height attributes and set the orientation as horizontal -->
<!-- Place the 'Latest News' and other buttons here -->
</LinearLayout>
<ListView>
<!-- Usual width/height attributes -->
</ListView>
</LinearLayout>