layout_gravity doesnt work - android

I have a layout with 7 buttons, I want 6 of them centered in the screen and the last one at bottom.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/background"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical" >
<ImageButton
android:id="#+id/account_but"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="50dip"
android:background="#null"
android:contentDescription="#string/accountDesc"
android:src="#drawable/boton_usos" />
<ImageButton
android:id="#+id/alquilar_but"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:background="#null"
android:contentDescription="#string/alquilarDesc"
android:src="#drawable/boton_alquilar" />
<ImageButton
android:id="#+id/paradas_but"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:background="#null"
android:contentDescription="#string/paradasDesc"
android:src="#drawable/boton_paradas" />
<ImageButton
android:id="#+id/noticias_but"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:background="#null"
android:contentDescription="#string/noticiasDesc"
android:src="#drawable/boton_noticias" />
<ImageButton
android:id="#+id/incidencia_but"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:background="#null"
android:contentDescription="#string/incidenciaDesc"
android:src="#drawable/boton_incidencia" />
<ImageButton
android:id="#+id/informacion_but"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:background="#null"
android:contentDescription="#string/infoDesc"
android:src="#drawable/boton_informacion" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical" >
<ImageButton
android:id="#+id/sabadell_but"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/banner_sabadell"
android:contentDescription="#string/infoDesc" />
</LinearLayout>
</LinearLayout>
With this code, I got the buttons start at left top.
How can I fix it?

Use android:gravity instead of layout_gravity.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
>
I implement it and It is working.
EDIT:
I put Entire XML.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<Button
android:id="#+id/account_but"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="50dip"
android:text="Button 1" />
<Button
android:id="#+id/alquilar_but"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:text="Button 2" />
<Button
android:id="#+id/paradas_but"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:text="Button 3" />
<Button
android:id="#+id/noticias_but"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:text="Button 4" />
<Button
android:id="#+id/incidencia_but"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:text="Button 5" />
<Button
android:id="#+id/informacion_but"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:text="Button 6" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:id="#+id/sabadell_but"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text="Button 7" />
</LinearLayout>
</LinearLayout>
And Output.

Try this: Use android:gravity="center" insted of android:layout_gravity="center"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/background"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
>
<ImageButton
android:id="#+id/account_but"
android:background="#null"
android:contentDescription="#string/accountDesc"
android:layout_marginTop="50dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/boton_usos" />
<ImageButton
android:id="#+id/alquilar_but"
android:background="#null"
android:contentDescription="#string/alquilarDesc"
android:layout_marginTop="5dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/boton_alquilar" />
<ImageButton
android:id="#+id/paradas_but"
android:background="#null"
android:contentDescription="#string/paradasDesc"
android:layout_marginTop="5dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/boton_paradas" />
<ImageButton
android:id="#+id/noticias_but"
android:background="#null"
android:contentDescription="#string/noticiasDesc"
android:layout_marginTop="5dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/boton_noticias" />
<ImageButton
android:id="#+id/incidencia_but"
android:background="#null"
android:contentDescription="#string/incidenciaDesc"
android:layout_marginTop="5dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/boton_incidencia" />
<ImageButton
android:id="#+id/informacion_but"
android:background="#null"
android:contentDescription="#string/infoDesc"
android:layout_marginTop="5dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/boton_informacion" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="bottom"
>
<ImageButton
android:id="#+id/sabadell_but"
android:background="#drawable/banner_sabadell"
android:contentDescription="#string/infoDesc"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
</LinearLayout>

Giving you the my full XML file, as i had worked on it in my app
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/bg_mainscreen">
<LinearLayout
android:id="#+id/lnrContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical" >
<Button
android:id="#+id/btnRecipe"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="80dip"
android:layout_marginRight="80dip"
android:background="#string/RecipeButton_background"/>
<Button
android:id="#+id/btnIngredients"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="80dip"
android:layout_marginRight="80dip"
android:layout_marginTop="20dip"
android:background="#string/IngredientButton_background"/>
<Button
android:id="#+id/btnMenu"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="80dip"
android:layout_marginRight="80dip"
android:layout_marginTop="20dip"
android:background="#string/MenuButton_background" />
<Button
android:id="#+id/btnShoppingList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="80dip"
android:layout_marginRight="80dip"
android:layout_marginTop="20dip"
android:background="#string/ShoppingListButton_background"/>
<Button
android:id="#+id/btnSynctoServer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="80dip"
android:layout_marginRight="80dip"
android:layout_marginTop="20dip"
android:text="Synchronize"
android:textColor="#android:color/black"
android:background="#string/ShoppingListButton_background"/>
</LinearLayout>
<Button
android:id="#+id/btnSynctoServer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Synchronize"
android:layout_marginLeft="80dip"/>
</RelativeLayout>

Related

how to align the button at bottom in linear layout?

I want to keep the adview layout at bottom in linear layout. i tried using gravity and layout_gravity at bottom but its not working,i had attached the code and snapshot too.
please give me any solution
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="#+id/linearmainlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/inner_screen_bg"
android:orientation="vertical"
android:weightSum="10" >
<LinearLayout
android:id="#+id/linear1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:orientation="horizontal"
android:paddingBottom="10dip"
android:paddingTop="5dip"
android:weightSum="100" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="20"
android:gravity="center_vertical"
android:orientation="vertical" >
<Button
android:id="#+id/fbShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#drawable/fb_btn"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Button
android:id="#+id/twitterShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#drawable/tw_btn"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Button
android:id="#+id/revealButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#drawable/reveal_btn"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<RelativeLayout
android:id="#+id/imageContainer"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginRight="10dip"
android:layout_marginTop="3dp"
android:layout_weight="60"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/imageView"
android:layout_width="320dip"
android:layout_height="150dip"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#drawable/image5" >
<ImageView
android:id="#+id/correctMark"
android:layout_width="80dip"
android:layout_height="80dip"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="10dip"
android:layout_marginLeft="5dip"
android:src="#drawable/cleared_imag"
android:visibility="gone" />
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/ticketCounterContainer"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="20"
android:gravity="center_vertical"
android:orientation="vertical" >
<Button
android:id="#+id/ticket1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ticket"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Button
android:id="#+id/ticket2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ticket"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Button
android:id="#+id/ticket3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ticket"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</LinearLayout>
<EditText
android:id="#+id/movieName"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="#id/linear1"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_weight="1"
android:background="#drawable/input_field"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="10dip" />
<RelativeLayout
android:id="#+id/correctAnswerLayoutContainer"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_below="#id/movieName"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_weight="1"
android:background="#drawable/circular_rectangle_white_background"
android:paddingLeft="10dip"
android:visibility="gone" >
<LinearLayout
android:id="#+id/hintContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:layout_width="40dp"
android:layout_height="35dp"
android:src="#drawable/icon" />
<TextView
android:id="#+id/hintOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="#string/musical_moview_text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/black"
android:textSize="15dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:layout_width="40dp"
android:layout_height="35dp"
android:src="#drawable/icon" />
<TextView
android:id="#+id/hintTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="#string/release_text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/black"
android:textSize="15dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:layout_marginTop="5dip"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:layout_width="40dp"
android:layout_height="35dp"
android:src="#drawable/icon" />
<TextView
android:id="#+id/hintThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="#string/hint3_text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/black"
android:textSize="15dp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<Button
android:id="#+id/nextButton"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dip"
android:layout_weight="1"
android:background="#drawable/next_btn" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:layout_weight="1" >
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="#string/publisher_id"
ads:loadAdOnCreate="true" />
</LinearLayout>
</LinearLayout>
Try this..
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="#+id/linearmainlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:weightSum="10" >
<LinearLayout
android:id="#+id/linear1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:orientation="horizontal"
android:paddingBottom="10dip"
android:paddingTop="5dip"
android:weightSum="100" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="20"
android:gravity="center_vertical"
android:orientation="vertical" >
<Button
android:id="#+id/fbShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Button
android:id="#+id/twitterShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Button
android:id="#+id/revealButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<RelativeLayout
android:id="#+id/imageContainer"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginRight="10dip"
android:layout_marginTop="3dp"
android:layout_weight="60"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/imageView"
android:layout_width="320dip"
android:layout_height="150dip"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" >
<ImageView
android:id="#+id/correctMark"
android:layout_width="80dip"
android:layout_height="80dip"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="10dip"
android:layout_marginLeft="5dip"
android:src="#drawable/ic_launcher"
android:visibility="gone" />
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/ticketCounterContainer"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="20"
android:gravity="center_vertical"
android:orientation="vertical" >
<Button
android:id="#+id/ticket1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Button
android:id="#+id/ticket2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Button
android:id="#+id/ticket3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</LinearLayout>
<EditText
android:id="#+id/movieName"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="#+id/linear1"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_weight="1"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="10dip" />
<RelativeLayout
android:id="#+id/correctAnswerLayoutContainer"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_below="#+id/movieName"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_weight="1"
android:paddingLeft="10dip"
android:visibility="gone" >
<LinearLayout
android:id="#+id/hintContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:layout_width="40dp"
android:layout_height="35dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/hintOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="musical_moview_text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/black"
android:textSize="15dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:layout_width="40dp"
android:layout_height="35dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/hintTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="release_text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/black"
android:textSize="15dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:layout_marginTop="5dip"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:layout_width="40dp"
android:layout_height="35dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/hintThree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="hint3_text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/black"
android:textSize="15dp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<Button
android:id="#+id/nextButton"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dip"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="55dp"
android:orientation="vertical" >
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="#string/publisher_id"
ads:loadAdOnCreate="true" />
</LinearLayout>
</LinearLayout>
Put the button and Adview in a new relative layout below the linear layouts.

Scrollview issue in xml, doesn't work

I have a following code.. I want to scroll my text area and my buttons within in LinearLayout. But my bottom button which is in relativelayout i want to stay it always in bottom not scroll able.
Thanks
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="175dip"
android:background="#android:color/white">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:textSize="20dip"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="35dp"
android:textSize="15dip"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="55dp"
android:textSize="15dip"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="75dp"
android:textSize="15dip"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="95dp"
android:textSize="15dip"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="115dp"
android:textSize="15dip"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="135dp"
android:textSize="15dip"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="155dp"
android:textSize="15dip"
/>
</RelativeLayout>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="XYZ"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="XYZ"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="XYZ"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="XYZ"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Contact Us"/>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="50dip"
android:background="#android:color/black"
android:layout_alignParentBottom="true" >
<Button
android:id="#+id/buttonCheck"
android:layout_width="50sp"
android:layout_height="50sp"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:background="#drawable/round_button"
android:text="Checked" />
</RelativeLayout>
</RelativeLayout>
As you are using relative layout, first put the button at the bottom of screen, and then let scrollview occupy the the height available.
Try following code:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:id="#+id/rel_btn_Check"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:layout_alignParentBottom="true"
android:background="#android:color/black" >
<Button
android:id="#+id/buttonCheck"
android:layout_width="50sp"
android:layout_height="50sp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#drawable/round_button"
android:text="Checked" />
</RelativeLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#id/rel_btn_Check"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="175dip"
android:background="#android:color/white" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:textSize="20dip" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="35dp"
android:textSize="15dip" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="55dp"
android:textSize="15dip" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="75dp"
android:textSize="15dip" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="95dp"
android:textSize="15dip" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="115dp"
android:textSize="15dip" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="135dp"
android:textSize="15dip" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="155dp"
android:textSize="15dip" />
</RelativeLayout>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="XYZ" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="XYZ" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="XYZ" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="XYZ" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Contact Us" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
</RelativeLayout>
use this mechanism
set scroll view >
android:layout_weight="1"
and put footer :
android:layout_alignParentBottom="true"
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical">
<ScrollView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1">
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="jgfhrtuioghju oioupotyuhjipouipoi typ[ipo[ip[ijup0[ip0[ujiptjuip[juip[i]]]]]]] jogi5thjuohuortthjuo90uto okithjoitthjuo thjpo ktjhporyjohj ptlhjyjohjpy plthjoyjpokjotjhojuyojuhoithjoi kgjhoithoithjuotjupojutpo[ujotpotpojuote]ihihoihoi rguigreuighreiuyghir orighoihyheiyhreiygh oighoihtgihidrfyh8irfyhuesghuyhuiehvguyh rueighuyghuiyghieryhirgeyhi gorfihoihklrjegoij5oi hi thkoihioghoirhirhuiurg] th5yj u trjuykyu yjytku yktyu k ykj k y jiyku ykj yuk yku k y 6ty 6y 6yy kuiil 6 u67 uokityy7 i78o8 "/>
</ScrollView>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true"><Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="rgfjughtih g5yujhoihuoi"/></LinearLayout></LinearLayout>

ScrollView control don't display more rows by scrolling

The tvReceiveNumber and tvOnlyOrExceptNumber controls have many rows, so I add a ScrollView control in my UI.
I think I can display more rows using ScrollView, but I failed, the ScrollView control don't scroll to diplay more rows.
How can I do? Thanks!
BTW, if you have better way to display many rows by scrolling screen and keep the toolbar buttons such as btnEdit, btnDeleet and btnClose always display on the bottom of screen, wolud you please tell me?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/border_ui" >
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="a15284e3e927f18"
ads:loadAdOnCreate="false" />
<LinearLayout
android:id="#+id/LinearLayoutName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/adView"
android:orientation="horizontal" >
<TextView
android:id="#+id/tvRuleNameTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rule Name" />
<TextView
android:id="#+id/tvRuleName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Rule Name" />
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayoutChecked"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/LinearLayoutName"
android:orientation="horizontal" >
<TextView
android:id="#+id/tvEnabledRule"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enabled Rule" />
<CheckBox
android:id="#+id/chEnabledRule"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
android:text="" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/LinearLayoutChecked" >
<LinearLayout
android:id="#+id/LinearLayoutOption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/tvReceiveTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Receiver"
/>
<TextView
android:id="#+id/tvReceiveNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1\n2\n3\n4\n5\n6\n7\n8\n9"/>
<TextView
android:id="#+id/tvOptionTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Forward Option" />
<TextView
android:id="#+id/tvOnlyOrExceptNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1\n2\n3\n4\n5\n6\n7\n8\n9\n10" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="center_vertical"
android:background="#DCDCDC"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/btnEdit"
style="#style/myTextAppearance"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:checked="true"
android:text="Edit" />
<Button
android:id="#+id/btnDelete"
style="#style/myTextAppearance"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Delete" />
<Button
android:id="#+id/btnClose"
style="#style/myTextAppearance"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Close" />
</LinearLayout>
</RelativeLayout>
The following code is not good too. The toolbar buttons such as btnEdit, btnDeleet and btnClose can't always display on the bottom of screen, I need to scroll UI to display toolbar, and more some rows of the tvOnlyOrExceptNumber control disappear, I don't know why?
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="a15284e3e927f18"
ads:loadAdOnCreate="false" />
<LinearLayout
android:id="#+id/LinearLayoutName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/adView"
android:orientation="horizontal" >
<TextView
android:id="#+id/tvRuleNameTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rule Name" />
<TextView
android:id="#+id/tvRuleName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Rule Name" />
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayoutChecked"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/LinearLayoutName"
android:orientation="horizontal" >
<TextView
android:id="#+id/tvEnabledRule"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enabled Rule" />
<CheckBox
android:id="#+id/chEnabledRule"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
android:text="" />
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayoutOption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/LinearLayoutChecked"
android:orientation="vertical" >
<TextView
android:id="#+id/tvReceiveTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Receiver"
/>
<TextView
android:id="#+id/tvReceiveNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1\n2\n3\n4\n5\n6\n7\n8\n9"/>
<TextView
android:id="#+id/tvOptionTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Forward Option" />
<TextView
android:id="#+id/tvOnlyOrExceptNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1\n2\n3\n4\n5\n6\n7\n8\n9\n10" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="center_vertical"
android:background="#DCDCDC"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/btnEdit"
style="#style/myTextAppearance"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:checked="true"
android:text="Edit" />
<Button
android:id="#+id/btnDelete"
style="#style/myTextAppearance"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Delete" />
<Button
android:id="#+id/btnClose"
style="#style/myTextAppearance"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Close" />
</LinearLayout>
The result image
try this one :)
Edit:
the last line was not appearing :)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/border_ui">
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="a15284e3e927f18"
ads:loadAdOnCreate="false" />
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="center_vertical"
android:background="#DCDCDC"
android:gravity="center"
android:orientation="horizontal">
<Button
android:id="#+id/btnEdit"
style="#style/myTextAppearance"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:checked="true"
android:text="Edit" />
<Button
android:id="#+id/btnDelete"
style="#style/myTextAppearance"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Delete" />
<Button
android:id="#+id/btnClose"
style="#style/myTextAppearance"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Close" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/adView"
android:id="#+id/scrollView1"
android:minWidth="25px"
android:minHeight="25px"
android:layout_above="#id/linearLayout1">
<RelativeLayout
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/relativeLayout1">
<LinearLayout
android:id="#+id/LinearLayoutName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/adView"
android:orientation="horizontal"
android:layout_alignParentTop="true">
<TextView
android:id="#+id/tvRuleNameTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rule Name" />
<TextView
android:id="#+id/tvRuleName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Rule Name" />
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayoutChecked"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/LinearLayoutName"
android:orientation="horizontal">
<TextView
android:id="#+id/tvEnabledRule"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enabled Rule" />
<CheckBox
android:id="#+id/chEnabledRule"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
android:text="" />
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayoutOption"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/LinearLayoutChecked">
<TextView
android:id="#+id/tvReceiveTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Receiver" />
<TextView
android:id="#+id/tvReceiveNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1\n2\n3\n4\n5\n6\n7\n8\n9" />
<TextView
android:id="#+id/tvOptionTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Forward Option" />
<TextView
android:id="#+id/tvOnlyOrExceptNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1\n2\n3\n4\n5\n6\n7\n8\n9\n10" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
ScrollView needs to be the root element in your xml. Add your elements to a LinearLayout or a RelativeLayout that is the first and only child of your ScrollView.

Trouble getting relative layout right

I have been pulling my hair out trying to get my relative layout setup the way I want. I want to have a EditText on the left with a TextView in the middle and a Button to the right and all those over a ListView Here is as close as I can get ...
Here is the xml I am using:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<EditText
android:id="#+id/new_bookmark_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/new_bookmark_clock"
android:ems="10"
android:inputType="text" />
<TextView
android:id="#+id/new_bookmark_clock"
android:layout_width="12sp"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/btn_add_new_bookmark"
android:text="#string/xx_xx_xx" />
<Button
android:id="#+id/btn_add_new_bookmark"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="#string/add" />
<ListView
android:id="#+id/bookmark_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/new_bookmark_name" />
</RelativeLayout>
Can anyone help me out?
You can better achieve it through LinearLayout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<EditText
android:id="#+id/new_bookmark_name"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/new_bookmark_clock"
android:ems="10"
android:inputType="text" />
<TextView
android:id="#+id/new_bookmark_clock"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/btn_add_new_bookmark"
android:text="#string/xx_xx_xx" />
<Button
android:id="#+id/btn_add_new_bookmark"
style="?android:attr/buttonStyleSmall"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="#string/add" />
</LinearLayout>
Try this
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<EditText
android:id="#+id/new_bookmark_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/new_bookmark_clock"
android:layout_alignBaseline="#+id/btn_add_new_bookmark"
android:ems="10"
android:inputType="text" />
<TextView
android:id="#+id/new_bookmark_clock"
android:layout_width="wrap_content"
android:layout_alignBaseline="#+id/btn_add_new_bookmark"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/btn_add_new_bookmark"
android:text="#string/xx_xx_xx" />
<Button
android:id="#+id/btn_add_new_bookmark"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="#string/add" />
<ListView
android:id="#+id/bookmark_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/new_bookmark_name" />
</RelativeLayout>
you can use this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="#+id/new_bookmark_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.5"
android:ems="10"
android:inputType="text" />
<TextView
android:id="#+id/new_bookmark_clock"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.3"
android:text="XXXXXXXXX" />
<Button
android:id="#+id/btn_add_new_bookmark"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.2"
android:text="Add" />
</LinearLayout>
<ListView
android:id="#+id/bookmark_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/new_bookmark_name" />
</LinearLayout>
Try with below
change android:layout_width="12sp" to android:layout_width="wrap_content"
<EditText
android:id="#+id/new_bookmark_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/new_bookmark_clock"
android:ems="10"
android:inputType="text" />
<TextView
android:id="#+id/new_bookmark_clock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/btn_add_new_bookmark"
android:text="xx_xx_xx" />
<Button
android:id="#+id/btn_add_new_bookmark"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="add" />
<ListView
android:id="#+id/bookmark_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/new_bookmark_name" />
</RelativeLayout>
The problem that you were providing fixed width to Textview which create problem, I just added one more Relative Layout which achieve your goal, have a look below code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:id="#+id/layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/new_bookmark_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:ems="10"
android:inputType="text" />
<TextView
android:id="#+id/new_bookmark_clock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_toRightOf="#+id/new_bookmark_name"
android:gravity="center"
android:text="xx_xx_xx" />
<Button
android:id="#+id/btn_add_new_bookmark"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_centerInParent=""
android:text="add" />
</RelativeLayout>
<ListView
android:id="#+id/bookmark_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/layout" />
</RelativeLayout>
try this one:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="#+id/new_bookmark_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="text" />
<TextView
android:id="#+id/new_bookmark_clock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/xx_xx_xx" />
<Button
android:id="#+id/btn_add_new_bookmark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/add" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:id="#+id/bookmark_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/new_bookmark_name" />
</LinearLayout>
</LinearLayout>
you can try it like this , this way it keeps your top_bar seperate from list view . Also for textview never use dp . Sp is used for text size.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id ="#+id/top_bar">
<EditText
android:id="#+id/new_bookmark_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/new_bookmark_clock"
android:ems="10"
android:inputType="text" />
<TextView
android:id="#+id/new_bookmark_clock"
android:layout_width="12sp"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/btn_add_new_bookmark"
android:text="#string/xx_xx_xx" />
<Button
android:id="#+id/btn_add_new_bookmark"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="#string/add" />
</RelativeLayout
<ListView
android:id="#+id/bookmark_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>

Header Layout Hidden When Scrolling With Soft Keyboard Shown

I have a strange error with ScrollView.
When the soft keyboard is not shown, scrolling works fine on both 2.2, 2.3 and 4.0.
But when the soft keyboard is shown, scrolling makes header layout invisible on 2.2 and 2.3.
What's wrong with my layout?
Please give me your suggestion.
This is my layout :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/white"
android:orientation="vertical" >
<include
android:id="#+id/header"
layout="#layout/b2u_header" />
<ScrollView
android:id="#+id/ScrollView02"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="15dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="15dp"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="#string/msg_register"
android:textColor="#color/black_color" />
<include
android:id="#+id/friend_name_table"
layout="#layout/b2u_profile_friend_name_table" />
<include
android:id="#+id/other_info"
layout="#layout/b2u_profile_settings_other_info" />
<LinearLayout
android:id="#+id/layout_password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:gravity="center_vertical"
android:text="#string/password"
android:textColor="#000000" />
<EditText
android:id="#+id/edt_password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:hint="パスワード"
android:inputType="textPassword" />
<EditText
android:id="#+id/edt_password_rewrite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:hint="確認用パスワード"
android:inputType="textPassword" />
</LinearLayout>
<TextView
android:id="#+id/question_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:gravity="center_vertical"
android:text="■パスワードを忘れた時のヒント"
android:textColor="#000000" />
<Spinner
android:id="#+id/spinner_reminder_questions"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:entries="#array/reminder_questions" >
</Spinner>
<TextView
android:id="#+id/answer_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:gravity="center_vertical"
android:text="こたえ"
android:textColor="#000000" />
<EditText
android:id="#+id/answer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:gravity="center_vertical" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:gravity="center_vertical"
android:text="■ メールマガジンを受け取る"
android:textColor="#000000" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<RadioGroup
android:id="#+id/confirmemail_group"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/rb_notreceive"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="受け取らない"
android:textColor="#000000" />
<RadioButton
android:id="#+id/rb_receive"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="受け取る"
android:textColor="#000000" />
</RadioGroup>
</LinearLayout>
<LinearLayout
android:id="#+id/layout_agree_term"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:gravity="center_vertical"
android:text="■ 利用規約、プライバシーポリシーの同意"
android:textColor="#000000" />
<TextView
android:id="#+id/term_btn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:textColor="#000000" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="horizontal" >
<CheckBox
android:id="#+id/agree_term"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" 同意する" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>

Categories

Resources