how to make the position of button fixed in android?
I have a button and a expand list above this button , when the list is expanded the b开发者_StackOverflow社区utton below it disappears . how to make this button in fixed location?
<?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">
<include layout="@layout/ads_bar" ></include>
<TextView
android:text="Level 1:"
android:textSize="20dp"
android:id="@+id/TextView01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"></TextView>
<TextView
android:text="lorem ispum something about this level ..... :)"
android:textSize="16dp"
android:id="@+id/TextView01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"></TextView>
<ExpandableListView
android:id="@+id/listView"
android:scrollbars="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"></ExpandableListView>
<include
android:layout_alignParentBottom="true"
layout="@layout/quick_links_bar"></include>
</LinearLayout>
where quick_links_bar
represents button !
To acheve button aligned to the bottom it's better to use layout_weight attribute of the linear layout.
Simple example:
<LinearLayout>
<TextView layout_weight=1/>
<Button layout_height="wrap_content"/>
<LinearLayout>
This is better than using RElative layout because if using one you will have the bottom of your text cut off by the button, but in this case it will not happen.
Sounds like you want the quick_links_bar
layout to always stay at the bottom? You'll need to use RelativeLayout
for that.
Wrap your whole layout in a RelativeLayout and move your quick links bar layout outside of the LinearLayout and set the property android:layout_alignParentBottom="true"
on it. For this next bit, you'll need to assign an id to your quick links bar. On your LinearLayout, set the property android:layout_above="@id/quicklinksbarid"
. Make sure your quick links bar include statement is above the LinearLayout.
精彩评论