In my android app when the no of items in the list is small the footer sticks to end of the list like the one shown below.
but not to the end of screen.
Is there any way that i can stick it to the bottom of the screen.
I am using a seperate footer.xml and am calling it using Inflator service.
Please share your valuable suggestions.
Thanks in advance:)
Use Relative layout and align it to bottom of parent:
<RelativeLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<YourFooter
android:id="#+id/SomethingSomething"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
</RelativeLayout>
Related
I have read https://stackoverflow.com/a/2620252/779408 and know how to add a header to listview. But this header is not fixed when the user scroll down the list.
How can I fix the place of the header of ListView when the user scroll the list and make it visible always on top?
The better way is set the header statically in a separated layout (ouside your ListView). An example that illustrates this could be:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:id="#+id/YOUR_HEADER_VIEW"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
You have to replace the View with your header's view.
I hope this solve your problem.
maybe just put your header out of the list. make the view to stick on top of the list and work on the design so it looks like it is inside the list.
i am working on a app, where i need to display the google map on the right half of the screen of my device. The left half of the screen contain text in list view format. Please help me how to design the UI part or layout.xml.....Thanks in advance..!!!
Use linear layout with horizontal orientation and put both your mapview and listview inside it , now give similar weight to them .May be that will work .for example give layout_weight 1 or 0.5 in both mapview and listview .
Try use Fragments and here are some links to training
Using Fragments in Android
trading for fragments
Maybe you could look into something like this? I've used this format in apps before
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:gravity="center"
android:orientation="vertical">
<MapView />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:gravity="center"
android:orientation="vertical">
<ListView />
</LinearLayout>
I'm currently trying to place a progress bar on the top left corner of my screen. However, I'm not quite sure which way is the best way to do it. Should I create a progress bar programatically instead of creating it in the xml? Or should I change my layout around? Thanks. XML below.
XML CODE:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/background"
android:focusableInTouchMode="true"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="53dp"
android:layout_marginBottom="5dp"
android:src="#raw/topbar" />
<TextView
android:id="#+id/search_nameOfFeed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:text="Event Name"
android:textColor="#color/black"
android:textSize="18sp" >
</TextView>
<ListView
android:id="#+id/searchfeed_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0.83"
android:dividerHeight="10.0sp"
android:fadingEdge="none"
android:stackFromBottom="false"
android:transcriptMode="normal" >
</ListView>
</LinearLayout>
The best option for layout when you're wanting to position views in specific areas is FrameLayout or RelativeLayout
RelativeLayout will allow you to place each view relative to each other.
FrameLayout allows you to stack views in a z-index positioning.
Play with both and you may come up with results you're looking for.
The best way to design layouts in android is by creating them in XML so you should do it in XML. You can achieve what you want by adding your ProgressBar before your ImageView
I doubt this is what you're looking for exactly, but another way you might want to implement a non-intrusive progress bar is to put it in the title bar of the activity. Check out this for an example of how to do this.
You can create it either way (In XML or Programatically). If you created it progamatcially, set the gravity to top and if you are creating in XML, use Relative Layout instead of Linear Layout and use android:layout_gravity="top|left". If you want to show it at the center follow the link
I'm trying to mimic the behaviour of the HTC SMS application (tradional view), where all messages are shown, and an EditTextis shown below. As you can see in the screenshot, when scrolling upwards, the EditText scrolls away at the bottom.
I'm stuck with this, even after reading multiple posts (eg Android Layout with ListView and Buttons and this website: http://www.finalconcept.com.au/article/view/android-keeping-buttons-visible), it's not working as expected.
Thanks to the comments and EditText now showing under ListView, I've managed to have my ListView take all available space and start scrolling once completed. The EditText is showing at the bottom of the screen now - always. I'd like it to disappear at the bottom when I scroll up though - now it remains at the bottom
Current Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="#android:id/android:list"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
<TableLayout
android:layout_weight="0"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow>
<EditText android:id="#+id/newmessagecontent"
android:layout_height="150dp"
android:singleLine="false"
android:gravity="top"
android:layout_width="250dp"
android:layout_alignParentTop="true"
/>
<Button android:layout_height="wrap_content"
android:id="#+id/sendmessage"
android:text="Send"
android:layout_width="wrap_content"
/>
</TableRow>
</TableLayout>
</LinearLayout>
i think what you need to implement here is some sort of modification of the SeparatedListAdapter from Jeff Sharkey from this Article. In this article he not only manages to add two Adapters to a ListView but also explains how to have Headers to separate them if you want (you can remove that part of the code).
So what i mean, is your first Adapter will be the data with It's rows, and the second Adapter will be a dummy one with no data that just points to a View with your controls or whatever.
this way the ListView and what you want to add at the bottom are gonna be all scrollable.
Hope this helps.
A ListView automatically scrolls if all the items in it take up more space than the view provides. What happens if you remove the ScrollView?
recently the android market and shopsavvy underwent UI overhauls. The result is a list then seems to slide under a curved top area with buttons on it. The top section seems to cast a slight dropshadow on the list and the list itsself has a different coloured heading to the rest of the list. It's a really big improvement on the look of android UI's , much more professional looking.
So how is the sliding under the curved top section with drop shadow achieved?
thanks guys
There was a great blog post by the developers that made the market app, and you can find it here http://www.pushing-pixels.org/2010/12/13/meet-the-green-goblin-part-1.html
At shopsavvy we took a much simpler approach and achieved generally the same results. We use a frame layout with two sub layouts that overlap each other. The top layout has as background that is a custom image that includes the shadow (we have an awesome graphics guy). The bottom layout is simply a list view that has with a margin on top to place it where we want. The pseudocode for it looks like this.
<FrameLayout>
<!-- Listview that sits under another view -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:id="#+id/backgroundlist"
android:layout_marginTop="150dp"
android:layout_height="fill_parent"
android:layout_width="fill_parent" />
</LinearLayout>
<!-- view that sits on top -->
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:background="#drawable/curvedimage"
android:orientation="vertical"
>
<!-- headers, buttons and other stuff -->
<LinearLayout
.....
</LinearLayout>
</FrameLayout>
For the heading on the listview you just use the addHeaderView function on a listview. You simply make a layout for the header that you want. In our case we just use a text view with a different background color.
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:text="#string/scans_right_now"
android:layout_height="61dp"
android:layout_width="fill_parent"
android:gravity="bottom|center_horizontal"
android:paddingBottom="3dp"
android:textColor="#8b8b8b"
android:background="#d3d3d3"
android:textStyle="bold"
android:shadowColor="#FFFFFF"
android:shadowDx="0.0"
android:shadowDy="1.0"
android:shadowRadius="1.0" />
and then add that view as a header inside of your activity like so:
ListView list = (ListView) findViewById(R.id.backgroundlist);
View recentScansHeader = getLayoutInflater().inflate(R.layout.recent_products_header, recentViewList, false);
list.addHeaderView(recentScansHeader);