Android view partly on top of scrollable active listview - android

I'm creating a music player where I have a listview-activity to choose songs from. Whenever I choose a song I need a smaller view to pop-up on the bottom of the screen, on top of the listview, just like edit-text when the keyboard pops-up.
But I also want to still be able to scroll the listview(when the song is playing) without the smaller view disappearing from the screen.
The smaller view will contain buttons for the player.
Is this possible?
If so, what is the best way to do this?
Any ideas?

A simple way of doing this could be to reserve as space for the smaller view and then set it's visibility to invisible, then when the song is picked set it's visibility to visible layoutelement.setVisibility(View.VISIBLE);
where your layout element is the piece who's visibility you are changing.
Since your whole layout is within a scroll view when your layout visibility is set to visible the other components of your layout will be pushed below and you'll be able to scroll through it all.

Related

Android check either scrollview is scrollable or not

In my app I have a scroll view with n number of data to be listed out. There are two buttons one is named as UP placed above scroll view and the other is DOWN placed below scroll view.
Using the UP and DOWN buttons the list of views can be scrolled.
When the scroll bar is in top the Up button will be invisible and when the scroll bar reaches the bottom the DOWN button will become invisible, I have written logic for this using the getScrollX() method.
Now my problem is when there is very few data for example 3, the scroll bar will not be visible and the layout cannot be scrolled, in such a case both the UP and DOWN buttons need to be in invisible. How to do this, please suggest me a way?
You can try and use a ViewTreeObserver to check the dimension of the View inside your ScrollView. If the dimension exceeds a certain limit (such as the screen size), the ScrollView will be scrollable. See this preview SO answer for more details. Hope that helps!

Android - How to bring to front a webview

I have two Webviews but at certain point i would like to bring the one on the back to front. I want both visible.
Is it possible to change the layout order?
There is no concept of Z-axis position in Android view stack so you can't bring views to front or send to back. You need to set the view's visibility flag to hide, visible or invisible (.setVisibility(GONE , VISIBLE, or INVISIBLE) respectively). If you want them both visible at times then you need to have at least the top view (the one added to the parent view last) be with transparent background so that if their Visibilities are set to VISIBLE then the behind view will show through the top view.
Kevin

Laying out views below a ScrollView/ListView

My question is a bit specific, I have a ListView of items above a button all inside a dialog. I want my ListView to never be greater than 280dip but always have the button below the ListView, no matter how large this ListView may be. My concern is when the dialog is switched to landscape mode, the button disappears because it is pushed out of the view by the ListView above that I have set to have android:layout_height="280dip". Obviously, this means that the ListView will always be 280dip, but is there a way to make it so that the ListView can change its size so it can always fit the button below it no matter the screen size/dimensions? I don't want to fill the parent of the height in the dialog because I don't want the dialog to be stretched out all the way in portrait mode. I'm sure there is a simple solution to this, but I wasn't sure how to word it in a manner that was more general.
If you want a View to take up the rest of layout, you should set a weight for the View.
Try giving the following settings for the ListView and see what happens.
android:layout_weight="1"
android:layout_height="0dp"
If you want the button to always be right below the listview and keep it visible despite the varying screen sizes, just create a new layout that contains a button and initialize that layout in your java code. Then do listView1.addFooterView(layoutView) and the layout with the button will be attached to the bottom of the listview. This can help you further with setting a footer view to the listview.
View footerView = ((LayoutInflater)MyActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.footer_layout, null, false);
listView1.addFooterView(footerView);

Sliding in a layout for user input

I have a ListView and each item contains a TextView displaying a number. I'd like to give my users the ability to change this number while staying on the ListView (as opposed to drilling down into a detailed view by clicking on the list item).
What I'm looking to do is to slide in a layout from the bottom of the screen that covers about half of the screen. I'd like this layout to be OVER the Activity behind it (as opposed to being part of that Activity's layout and simply showing it). I'd also like it to be model (or seem modal). Meaning the Activity behind it can not be focused and manipulated. In this layout I will essentially create a calculator.
What I need help with right now is:
1) How to display a layout over the current Activity
2) How make the background (the Activity) modal
Could someone point me to some tutorials/resources and/or give me a few tips?
use an Animation. here is a small tutorial on them: http://developerlife.com/tutorials/?p=343
initially, the view you want to be modal must be placed where you want it to show up(and visibility set to gone).
use a translate animation to visually move the view from below the screen to halfway up the screen. once the animation starts, set visibility to visible
try disabling all views that the user should not be able to interact with after you have started the animation holding the calculator view

Setting visible focus on text view

I've got listview that in a row it contain 3elements: imageview, textvie and another imageview. I've set my listview to setItemsCanFocus(true) and every item is set setFocusable(false). Screen:
http://img252.imageshack.us/img252/4042/zrzutekranue.png
I can navigate on the screen (click on text/image, I have those fields set to clickable and focusable), but there is no visible focus. I'd like to have the default focus style, when background changes.
I can add sth like:
setBackgroundColor(xxx)
but I'd like to have that fancy background that is lighter in the middle and darker at the ends.
The upper row on the pic is what I've got, and lower is the ideal focus notification, of course it should be narrow so it would only be background of the text view.
Sorry for my English.
PS I also used for textview
android:layout_height="fill_parent"
to fill for height which isn't the best piece of coding.
In the List View, all the list items are in different views. In your case the Image View, Text View And Image View lies within a single View. So according to me you cannot have focus on the items within a single View in a list View.

Categories

Resources