I have created a relative layout in which it requires only bottom border. How can I do that? Below is the RelativeLayout that I have used.
I have added view inside relative layout but it shows at bottom of screen
<?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="#EAEAEA"
android:orientation="vertical" >
<TextView
android:id="#+id/auth_lbl_register_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#EAEAEA"
android:clickable="true"
android:ellipsize="none"
android:fontFamily="FNB Sans"
android:gravity="left"
android:maxLines="50"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
android:scrollHorizontally="false"
android:text="#string/auth_into"
android:textColor="#color/labelColor"
android:textSize="20sp" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#drawable/border"
android:orientation="horizontal" >
<TextView
android:id="#+id/cellnum_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:fontFamily="FNB Sans"
android:text="#string/cell_num_label"
android:textColor="#color/labelColor"
android:textSize="15sp" />
<EditText
android:id="#+id/auth_txt_msisdn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="25dp"
android:layout_toRightOf="#+id/cellnum_text"
android:ellipsize="start"
android:ems="10"
android:gravity="center_horizontal"
android:hint="Enter cell number"
android:inputType="number"
android:singleLine="true"
android:textSize="15sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="5sp"
android:paddingRight="5sp" >
<CheckBox
android:id="#+id/auth_cbx_agree_terms"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:button="#drawable/check_box"
android:clickable="true"
android:ellipsize="none"
android:fontFamily="FNB Sans"
android:gravity="left"
android:maxLines="50"
android:paddingLeft="10dp"
android:paddingStart="30dp"
android:scrollHorizontally="false"
android:text="#string/auth_agree_terms"
android:textColor="#color/labelColor"
android:textSize="20sp" />
</RelativeLayout>
<!-- next -->
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/auth_cmd_validate"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_weight="0.9"
android:background="#F49B00"
android:gravity="center"
android:paddingLeft="0dp"
android:text="Next"
android:textColor="#color/labelColor"
android:textSize="20dp"
android:textStyle="normal" />
<ImageView
android:layout_width="40dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:src="#drawable/next_arrow_white" />
</RelativeLayout>
<!-- end of next -->
<TextView
android:id="#+id/or_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="#EAEAEA"
android:clickable="false"
android:fontFamily="FNB Sans"
android:gravity="center"
android:padding="10sp"
android:text="OR"
android:textColor="#color/labelColor"
android:textSize="20sp" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/auth_cmd_register"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_weight="0.9"
android:background="#color/white"
android:gravity="center"
android:paddingLeft="0dp"
android:text="Register Online"
android:textColor="#color/labelColor"
android:textSize="20dp"
android:textStyle="normal" />
<ImageView
android:id="#+id/imgArrowRight"
android:layout_width="40dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:gravity="center"
android:src="#drawable/line_arrow" />
<View
android:id="#+id/view"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_alignParentBottom="true"
android:background="#color/black" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/auth_cmd_terms"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_weight="0.9"
android:background="#ffffff"
android:gravity="center"
android:paddingLeft="0dp"
android:text="Terms and Condition"
android:textColor="#color/labelColor"
android:textSize="20dp"
android:textStyle="normal" />
<ImageView
android:id="#+id/imgArrowRight1"
android:layout_width="40dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:gravity="center"
android:src="#drawable/line_arrow" />
</RelativeLayout>
You need to specify android:layout_height="N" where N is your height in dp when using android:layout_alignParentBottom="true" :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/relativeLayoutOne"
android:layout_width="fill_parent"
android:layout_height="200dp">
<!-- Bottom Border shows -->
<View android:layout_alignParentBottom="true"
android:layout_height="1dp"
android:background="#F00"
android:layout_width="fill_parent"/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayoutTwo"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:text="Text View 1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayoutThree"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:text="Text View 2"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
</LinearLayout>
You can use View to give bottom border to your RelativeLayout.
Add this in your RelativeLayout.
<View
android:id="#+id/view"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_alignParentBottom="true"
android:background="#color/black" />
I hope it helps!
You can add a new ImageView to your RelativeLayout, set the height to 1 px, align it to the bottom, then this ImageView can be 'considered' as the border.
pleas see following xml:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="55dp" >
<TextView
android:id="#+id/txtCategoryName"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_weight="0.9"
android:background="#ffffff"
android:gravity="center"
android:paddingLeft="0dp"
android:text="Register"
android:textColor="#color/labelColor"
android:textSize="20dp"
android:textStyle="normal" />
<ImageView
android:id="#+id/imgArrow"
android:layout_width="40dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:gravity="center"
android:src="#drawable/line_arrow" />
<ImageView
android:id="#+id/imgBorder"
android:layout_width="fill_parent"
android:layout_height="1px"
android:layout_alignParentBottom="true"
android:background="#ff0000"/>
</RelativeLayout>
#inner_class7 is correct, you need to give a value as the height of the RelativeLayout, or, it will show on the bottom of the screen.
Related
In my action bar, I want the icon and title text to be centered horizontally. Here's what I'm getting:
The action bar is using a RelativeLayout. The icon image and title text are in a LinearLayout which has android:layout_centerHorizontal="true", but the linear layout is not centering. Here's the layout file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dip"
android:background="#dddddd" >
<ImageButton
android:id="#+id/leftButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:background="#null"
android:contentDescription=""
android:scaleType="centerInside"
android:src="#drawable/ic_drawer" />
<LinearLayout
android:id="#+id/titleParentLayout"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerHorizontal="true" >
<ImageView
android:id="#+id/titleImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:scaleType="centerInside"
android:src="#drawable/icon_orig" />
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:singleLine="true"
android:text="#string/app_name"
android:textColor="#484848"
android:textSize="18dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/rightSideParentLayout"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:background="#dddddd"
android:orientation="horizontal" >
<ImageButton
android:id="#+id/rightButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:background="#null"
android:contentDescription=""
android:scaleType="centerInside"
android:src="#drawable/addbutton" />
</LinearLayout>
</RelativeLayout>
EDIT: Both answers give me this:
As you can see, the icon and title are still not centered.
You can try using LinearLayout as follows...
<?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="50dip"
android:background="#dddddd"
android:orientation="horizontal" >
<ImageButton
android:id="#+id/leftButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:background="#null"
android:contentDescription=""
android:scaleType="centerInside"
android:src="#drawable/ic_drawer" />
<LinearLayout
android:id="#+id/titleParentLayout"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center" >
<ImageView
android:id="#+id/titleImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:scaleType="centerInside"
android:src="#drawable/ic_orig" />
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:singleLine="true"
android:text="#string/app_name"
android:textColor="#484848"
android:textSize="18dp" />
</LinearLayout>
<ImageButton
android:id="#+id/rightButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="right"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:background="#null"
android:contentDescription=""
android:scaleType="centerInside"
android:src="#drawable/addbutton" />
</LinearLayout>
in java code use this for android-version 3.0 to upper
getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getActionBar().setCustomView(R.layout.custom_actionbar);
xml file custom_actionbar
<?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="wrap_content"
android:orientation="horizontal"
android:background="#dddddd">
<ImageButton
android:id="#+id/leftButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dip"
android:background="#null"
android:contentDescription=""
android:scaleType="centerInside"
android:src="#drawable/ic_drawer" />
<LinearLayout
android:id="#+id/titleParentLayout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center" >
<ImageView
android:id="#+id/titleImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:scaleType="centerInside"
android:src="#drawable/icon_orig" />
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:singleLine="true"
android:text="#string/app_name"
android:textColor="#484848"
android:textSize="18sp" />
</LinearLayout>
<ImageButton
android:id="#+id/rightButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginRight="10dip"
android:gravity="center_vertical"
android:background="#null"
android:contentDescription=""
android:scaleType="centerInside"
android:src="#drawable/addbutton" />
</LinearLayout>
EDIT : Screenshot from Samsung tab2
I'm trying to create a layout like this:
Basically I have 2 Images that I would like to stick to either side of the LinearLayout and in the center have some text. I'm setting the width of the images in code based on the density of the screen, so that is of variable width.
Here is the code I have so far:
<RelativeLayout
android:id="#+id/user_header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/user_loading_wrapper"
android:layout_alignWithParentIfMissing="true"
android:layout_alignParentTop="true"
android:layout_margin="#dimen/default_spacing">
<!--User Poster-->
<ImageView
android:id="#+id/user_poster"
android:layout_width="50dp"
android:layout_height="50dp"
android:scaleType="fitXY"
android:contentDescription="User Poster"
android:layout_alignParentLeft="true"/>
<!--Review Details-->
<LinearLayout
android:id="#+id/screen_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/user_poster"
android:layout_alignParentTop="true"
android:gravity="center"
android:layout_centerInParent="true"
android:layout_marginLeft="#dimen/default_spacing_max"
android:orientation="vertical">
<!--User Title-->
<TextView
android:id="#+id/user_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#333"
android:singleLine="false"
android:layout_gravity="center"/>
<!--Location-->
<TextView
android:id="#+id/user_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#333"
android:singleLine="false"
android:layout_gravity="center"/>
<!--User 2 Title-->
<TextView
android:id="#+id/user_secondary_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#333"
android:layout_marginTop="4dp"
android:singleLine="false"
android:layout_gravity="center"
tools:text="Life of Pi"/>
</LinearLayout>
<!--Poster-->
<ImageView
android:id="#+id/user_poster_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitEnd"
android:layout_toRightOf="#id/screen_details"
android:contentDescription="Poster"
android:layout_alignParentRight="true"/>
</RelativeLayout>
But it doesn't work at all. I want the Center Layout to expand and occupy all the space in the middle between the two images.
i fixed it .... check output it in image and flow in code.
And Code is:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/user_header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignWithParentIfMissing="true" >
<ImageView
android:id="#+id/user_poster"
android:layout_width="60dp"
android:layout_height="60dp"
android:background="#android:color/black"
android:scaleType="fitXY" />
<LinearLayout
android:id="#+id/screen_details"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/user_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#android:color/darker_gray"
android:paddingLeft="10dp"
android:singleLine="false"
android:text="Life of Pi"
android:textColor="#333" />
<TextView
android:id="#+id/user_location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="4dp"
android:background="#android:color/darker_gray"
android:paddingLeft="10dp"
android:singleLine="false"
android:text="Life of Pi"
android:textColor="#333" />
<TextView
android:id="#+id/user_secondary_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="4dp"
android:background="#android:color/darker_gray"
android:paddingLeft="10dp"
android:singleLine="false"
android:text="Life of Pi"
android:textColor="#333" />
</LinearLayout>
<ImageView
android:id="#+id/user_poster2"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_weight="0"
android:background="#android:color/black"
android:scaleType="fitXY" />
</LinearLayout>
try this
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/user_header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignWithParentIfMissing="true"
android:layout_alignParentTop="true"
android:layout_margin="5dp">
<!--User Poster-->
<ImageView
android:id="#+id/user_poster"
android:layout_width="50dp"
android:layout_height="50dp"
android:scaleType="fitXY"
android:contentDescription="User Poster"
android:layout_alignParentLeft="true"/>
<!--Review Details-->
<LinearLayout
android:id="#+id/screen_details"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="70dp"
android:layout_toRightOf="#id/user_poster"
android:gravity="center"
android:orientation="vertical" >
<!--User Title-->
<TextView
android:id="#+id/user_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#333"
android:singleLine="false"
android:layout_gravity="center"/>
<!--Location-->
<TextView
android:id="#+id/user_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#333"
android:singleLine="false"
android:layout_gravity="center"/>
<!--User 2 Title-->
<TextView
android:id="#+id/user_secondary_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#333"
android:layout_marginTop="4dp"
android:singleLine="false"
android:layout_gravity="center"
android:text="Life of Pi"/>
</LinearLayout>
<!--Poster-->
<ImageView
android:id="#+id/user_poster_2"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:contentDescription="Poster" />
</RelativeLayout>
While developing a layout today I found some weird thing my Linear layout is not filling the available space .
//Image removed
My left layout is re-sizing according to content but i don't want that. What I want is the right edge of left hand side layout should touch the left edge of right layout.
I have tried both fill parent and wrap content with layout_weight but nothing is happening what i want is something like this.
// Image removed
My layout code :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:paddingLeft="7dp"
android:paddingRight="7dp">
<RelativeLayout
android:id="#+id/total_top_layout"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:paddingBottom="10dp"
android:layout_centerHorizontal="true">
<TextView
android:id="#+id/ammount_view"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="First Text Here"
android:textSize="20sp"
android:layout_centerVertical="true" />
<EditText
android:id="#+id/total_ammount_input"
android:layout_height="wrap_content"
android:layout_width="150dp"
android:singleLine="true"
android:layout_alignParentRight="true"
android:background="#color/hologreennewdark"
android:text="second Text"
android:layout_centerVertical="true"
android:padding="8dp"
android:gravity="center"
android:textColor="#color/WhiteSmoke" />
</RelativeLayout>
<View
android:id="#+id/divideaftertotal"
android:layout_width="#dimen/divide_width"
android:layout_height="#dimen/divider_height"
android:background="#color/YellowGreen"
android:layout_below="#+id/total_top_layout"
/>
<RelativeLayout
android:id="#+id/tens_view_top"
android:layout_below="#id/divideaftertotal"
android:layout_height="75dp"
android:layout_width="wrap_content"
>
<LinearLayout
android:id="#+id/tens_view_left"
android:layout_alignParentLeft="true"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerInParent="true"
>
<LinearLayout
android:id="#+id/firstcoloumn"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_weight="1"
>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="center"
android:orientation="horizontal"
>
<TextView
android:id="#+id/amount_rupee"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="Num1"
android:layout_centerVertical="true"
android:textSize="25sp" />
<TextView
android:id="#+id/multiply_sign"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="X"
android:layout_centerVertical="true"
android:textSize="26sp"
android:layout_toRightOf="#id/amount_rupee"
android:layout_marginLeft="40dp" />
<TextView
android:id="#+id/multiple_digit"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Num2"
android:layout_centerVertical="true"
android:textSize="25sp"
android:layout_toRightOf="#+id/multiply_sign"
android:layout_marginLeft="40dp" />
</LinearLayout>
<SeekBar
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_below="#+id/multiple_digit"
android:layout_marginTop="8dp"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_height="100dp"
android:layout_width="wrap_content"
android:background="#color/hologreendark"
android:layout_alignParentRight="true">
<TextView
android:id="#+id/amount_rupee"
android:layout_height="fill_parent"
android:layout_width="100dp"
android:text="Num3"
android:layout_centerVertical="true"
android:textSize="25sp"
android:gravity="center"
/>
</LinearLayout>
</RelativeLayout>
<View
android:id="#+id/divideaftertens"
android:layout_width="#dimen/divide_width"
android:layout_height="#dimen/divider_height"
android:background="#color/YellowGreen"
android:layout_below="#+id/tens_view_top"
/>
</RelativeLayout>
On the layout android:id="#+id/tens_view_left", you could add this 2 atributes:
android:layout_alignParentLeft="true"
so that its left side is anchored in its parent's left border, and
android:layout_toLeftOf="#id/id_from_the_linear_layout_on_the_right"
And that layout is:
<LinearLayout
android:id="#+id/id_from_the_linear_layout_on_the_right"
android:layout_height="100dp"
android:layout_width="wrap_content"
android:background="#color/hologreendark"
android:layout_alignParentRight="true">
<TextView
android:id="#+id/amount_rupee"
android:layout_height="fill_parent"
android:layout_width="100dp"
android:text="Num3"
android:layout_centerVertical="true"
android:textSize="25sp"
android:gravity="center"
/>
</LinearLayout>
By the way, you might need to set android:orientation="horizontal"
on the layout android:id="#+id/tens_view_top"
When using layout_weight, set the layout_width to 0dp (for horizontal orientation).
it could be like,
<LinearLayout
android:id="#+id/tens_view_left"
android:layout_alignParentLeft="true"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerInParent="true"
>
<LinearLayout
android:id="#+id/firstcoloumn"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="horizontal"
>
<LinearLayout
android:layout_height="fill_parent"
android:layout_width="0dp"
android:orientation="vertical"
android:layout_weight="1">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="center"
android:orientation="horizontal"
>
<TextView
android:id="#+id/amount_rupee"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="Num1"
android:layout_centerVertical="true"
android:textSize="25sp" />
<TextView
android:id="#+id/multiply_sign"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="X"
android:layout_centerVertical="true"
android:textSize="26sp"
android:layout_toRightOf="#id/amount_rupee"
android:layout_marginLeft="40dp" />
<TextView
android:id="#+id/multiple_digit"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Num2"
android:layout_centerVertical="true"
android:textSize="25sp"
android:layout_toRightOf="#+id/multiply_sign"
android:layout_marginLeft="40dp" />
</LinearLayout>
<SeekBar
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_below="#+id/multiple_digit"
android:layout_marginTop="8dp"
/>
</LinearLayout>
<LinearLayout
android:layout_height="100dp"
android:layout_width="wrap_content"
android:background="#color/hologreendark"
android:layout_alignParentRight="true">
<TextView
android:id="#+id/amount_rupee"
android:layout_height="fill_parent"
android:layout_width="100dp"
android:text="Num3"
android:layout_centerVertical="true"
android:textSize="25sp"
android:gravity="center"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Change the RelativeLayout to LinearLayout that contain two layout you want to have close, and add layout_weight=1 to first LinearLayout with layout_width=0dip like
<LinearLayout
android:id="#+id/tens_view_top"
android:layout_below="#id/divideaftertotal"
android:layout_height="75dp"
android:layout_width="wrap_content"
>
<LinearLayout
android:layout_weight="1"
android:id="#+id/tens_view_left"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="0dip"
>
<LinearLayout
android:id="#+id/firstcoloumn"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_weight="1"
>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="center"
android:orientation="horizontal"
>
<TextView
android:id="#+id/amount_rupee"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="Num1"
android:layout_centerVertical="true"
android:textSize="25sp" />
<TextView
android:id="#+id/multiply_sign"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="X"
android:layout_centerVertical="true"
android:textSize="26sp"
android:layout_toRightOf="#id/amount_rupee"
android:layout_marginLeft="40dp" />
<TextView
android:id="#+id/multiple_digit"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Num2"
android:layout_centerVertical="true"
android:textSize="25sp"
android:layout_toRightOf="#+id/multiply_sign"
android:layout_marginLeft="40dp" />
</LinearLayout>
<SeekBar
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_below="#+id/multiple_digit"
android:layout_marginTop="8dp"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_height="100dp"
android:layout_width="wrap_content"
android:background="#FFCCDD"
android:layout_alignParentRight="true">
<TextView
android:id="#+id/amount_rupee"
android:layout_height="fill_parent"
android:layout_width="100dp"
android:text="Num3"
android:layout_centerVertical="true"
android:textSize="25sp"
android:gravity="center"
/>
</LinearLayout>
// try this i have used LinearLayout rather than RelativeLayout
<?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:orientation="vertical"
android:padding="7dp">
<LinearLayout
android:id="#+id/total_top_layout"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center"
android:paddingBottom="10dp">
<TextView
android:id="#+id/ammount_view"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_width="0dp"
android:text="First Text Here"
android:textSize="20sp"/>
<EditText
android:id="#+id/total_ammount_input"
android:layout_height="wrap_content"
android:layout_width="150dp"
android:singleLine="true"
android:text="second Text"
android:padding="8dp"
android:gravity="center"/>
</LinearLayout>
<View
android:id="#+id/divideaftertotal"
android:layout_width="match_parent"
android:layout_height="1dp"/>
<LinearLayout
android:id="#+id/tens_view_left"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<LinearLayout
android:id="#+id/firstcoloumn"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center">
<LinearLayout
android:layout_height="match_parent"
android:gravity="center"
android:layout_width="0dp"
android:layout_weight="1">
<TextView
android:id="#+id/amount_rupee"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:text="Num1"
android:textSize="25sp" />
<TextView
android:id="#+id/multiply_sign"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:text="X"
android:layout_centerVertical="true"
android:textSize="26sp"
android:layout_marginLeft="40dp" />
<TextView
android:id="#+id/multiple_digit"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:text="Num2"
android:textSize="25sp"
android:layout_marginLeft="40dp" />
</LinearLayout>
</LinearLayout>
<SeekBar
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_below="#+id/multiple_digit"
android:layout_marginTop="8dp"/>
</LinearLayout>
<TextView
android:id="#+id/amount_rupee"
android:layout_height="match_parent"
android:layout_width="100dp"
android:text="Num3"
android:textSize="25sp"
android:gravity="center"/>
</LinearLayout>
<View
android:id="#+id/divideaftertens"
android:layout_width="match_parent"
android:layout_height="1dp"/>
</LinearLayout>
I have a LinearLayout in one of the activities as the main layout. I used Scrollview to encapsulated the LinearLayout. The Layout contains a fragment which displays a google map, but on scrolling it gave black background. I resolved the issue by using a transparent background inside a FrameLayout. The black background has gone, but during scrolling i get flickering black edges around the map. How to remove this? I tried setting the background of Scrollview to white color, but no change visible.
The XML of the activity is --
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:baselineAligned="false"
android:orientation="vertical"
android:overScrollMode="ifContentScrolls"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
android:showDividers="none" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="#ec4d1d" >
<TextView
android:id="#+id/friend_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="7dp"
android:background="#drawable/near_you_bg"
android:gravity="center_horizontal|center_vertical"
android:padding="6dp"
android:textColor="#FFFFFF"
android:textSize="15sp"
android:textStyle="bold"
android:typeface="sans" />
<Button
android:id="#+id/btnInviteFriends"
android:layout_width="30dp"
android:layout_height="25dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="7dp"
android:background="#drawable/menu_bg"
android:onClick="inviteFriends" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="81dp"
android:background="#drawable/list_bg"
android:orientation="vertical" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:shrinkColumns="*"
android:stretchColumns="*" >
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginTop="4dp"
android:gravity="center_vertical|center_horizontal" >
<RelativeLayout
android:layout_width="65dp"
android:layout_height="70dp" >
<ImageView
android:id="#+id/user_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignWithParentIfMissing="false"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="7dp"
android:src="#drawable/d_bg" />
</RelativeLayout>
<RelativeLayout
android:layout_width="140dp"
android:layout_height="70dp" >
<TextView
android:id="#+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:layout_toRightOf="#id/user_image"
android:paddingBottom="2dip"
android:text="Amrinder"
android:textColor="#000000"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/distance"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/name"
android:layout_marginTop="2dp"
android:layout_toRightOf="#id/user_image"
android:text="description"
android:textColor="#000000"
android:textSize="10sp" >
</TextView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/distance"
android:layout_marginTop="7dp"
android:orientation="horizontal" >
<ImageView
android:id="#+id/common_icon"
android:layout_width="26dp"
android:layout_height="19dp"
android:background="#drawable/common_icon" />
<TextView
android:id="#+id/common_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:text="4"
android:textColor="#000000"
android:textStyle="bold" />
<ImageView
android:id="#+id/friends_icon"
android:layout_width="26dp"
android:layout_height="19dp"
android:layout_marginLeft="7dp"
android:background="#drawable/friends_icon" />
<TextView
android:id="#+id/friends_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:text="5"
android:textColor="#000000"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="#+id/nearUserInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible" >
</TextView>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/time_ago"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10 min ago"
/>
<ImageView
android:id="#+id/dir_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/time_ago"
android:layout_centerHorizontal="true"
android:layout_marginTop="23dp"
android:background="#drawable/say_hi_button" />
</RelativeLayout>
</TableRow>
</TableLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
>
<ImageView
android:id="#+id/map_bar"
android:layout_width="fill_parent"
android:layout_height="25dip"
android:layout_centerInParent="false"
android:layout_gravity="center_horizontal"
android:background="#drawable/map_box_bg" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="25dp" >
<TextView
android:id="#+id/distance_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="1dp"
android:text="X is 4 km north-east of you now"
android:textColor="#ffffff"
android:textStyle="bold" />
</RelativeLayout>
<FrameLayout
android:id="#+id/frame_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="fill_parent"
android:layout_height="150dp"
android:layout_below="#id/map_bar"
/>
<View
android:id="#+id/trans_img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/trans" />
</FrameLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp" >
<ImageView
android:id="#+id/like_bar"
android:layout_width="fill_parent"
android:layout_height="25dip"
android:layout_gravity="center_horizontal"
android:background="#drawable/map_box_bg" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="25dp" >
<ImageView
android:id="#+id/like_button"
android:layout_width="24dp"
android:layout_height="23dp"
android:layout_centerVertical="true"
android:layout_marginLeft="1dp"
android:background="#drawable/common_detail_icon" />
<TextView
android:id="#+id/likes_in_common"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_toRightOf="#id/like_button"
android:gravity="center_vertical"
android:text=" 3 likes in common"
android:textColor="#FFFFFF"
android:textStyle="bold" />
</RelativeLayout>
<ImageView
android:id="#+id/like_bg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/like_bar"
android:layout_gravity="center_horizontal"
android:background="#drawable/list_bg" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp" >
<ImageView
android:id="#+id/friends_bar"
android:layout_width="fill_parent"
android:layout_height="25dip"
android:layout_gravity="center_horizontal"
android:background="#drawable/map_box_bg" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="25dp"
android:layout_alignParentRight="true" >
<ImageView
android:id="#+id/friends_button"
android:layout_width="24dp"
android:layout_height="23dp"
android:layout_centerVertical="true"
android:layout_marginLeft="1dp"
android:background="#drawable/common_friends_icon" />
<TextView
android:id="#+id/friends_in_common"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_toRightOf="#id/friends_button"
android:gravity="center_vertical"
android:text=" 9 friends in common"
android:textColor="#FFFFFF"
android:textStyle="bold" />
</RelativeLayout>
<ImageView
android:id="#+id/friends_bg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/friends_bar"
android:layout_gravity="center_horizontal"
android:background="#drawable/list_bg" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp" >
<ImageView
android:id="#+id/friends_bar"
android:layout_width="fill_parent"
android:layout_height="25dip"
android:layout_gravity="center_horizontal"
android:background="#drawable/map_box_bg" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="25dp"
android:layout_alignParentRight="true" >
<ImageView
android:id="#+id/friends_button"
android:layout_width="24dp"
android:layout_height="23dp"
android:layout_centerVertical="true"
android:layout_marginLeft="1dp"
android:background="#drawable/common_friends_icon" />
<TextView
android:id="#+id/friends_in_common"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_toRightOf="#id/friends_button"
android:gravity="center_vertical"
android:text=" 9 friends in common"
android:textColor="#FFFFFF"
android:textStyle="bold" />
</RelativeLayout>
<ImageView
android:id="#+id/friends_bg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/friends_bar"
android:layout_gravity="center_horizontal"
android:background="#drawable/list_bg" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp" >
<ImageView
android:id="#+id/friends_bar"
android:layout_width="fill_parent"
android:layout_height="25dip"
android:layout_gravity="center_horizontal"
android:background="#drawable/map_box_bg" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="25dp"
android:layout_alignParentRight="true" >
<ImageView
android:id="#+id/friends_button"
android:layout_width="24dp"
android:layout_height="23dp"
android:layout_centerVertical="true"
android:layout_marginLeft="1dp"
android:background="#drawable/common_friends_icon" />
<TextView
android:id="#+id/friends_in_common"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_toRightOf="#id/friends_button"
android:gravity="center_vertical"
android:text=" 9 friends in common"
android:textColor="#FFFFFF"
android:textStyle="bold" />
</RelativeLayout>
<ImageView
android:id="#+id/friends_bg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/friends_bar"
android:layout_gravity="center_horizontal"
android:background="#drawable/list_bg" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
Instead of using a transparent image above the map fragment you try using the transparent color becauz i was also facing the same issue and i solved using this method.
android:background="#android:color/transparent"
But technically speaking as suggested by Android you should not use a scrolling element inside another scrolling element.Rather you can use the Google map static map API to show static map inside scroll view and when you tap on scroll view you can open a Scrollable google map in a new window.
The reason behind this is that the Map uses a SurfaceView, when the App creates this view it creates a Window behind your Activity's and punches a hole meaning things in your Activity's window cannot seen underneath the SurfaceView's original location.
For me this is worked like charm, You can use this library
https://github.com/NyxDigital/NiceSupportMapFragment/
MY XMl code looks like :
<?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="wrap_content">
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="430dp"
android:fadingEdge="none"
>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/descriptionanth"
android:orientation="vertical"
android:id="#+id/searchjobslayout"
>
<ImageView android:id="#+id/homeimage_one" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_width="fill_parent" android:background="#drawable/logoblack"></ImageView>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="match_parent">
<TextView
android:id="#+id/keywords"
android:text="Search by keyword:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textStyle="bold"
android:textColor="#000000"
android:layout_marginLeft="10dp"
></TextView>
<EditText
android:id="#+id/keywordsedit"
android:hint=" Enter KeyWords"
android:layout_width="fill_parent"
android:layout_height="32dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textSize="14sp"
android:background="#drawable/text_field"
android:layout_marginTop="5dp"
android:textColorHint="#FFFFFF"
android:paddingLeft="10dp"
android:textColor="#000000"
></EditText>
<Button
android:id="#+id/search"
android:text="Search"
android:layout_width="fill_parent"
android:layout_height="35dp"
android:textColor="#FFFFFF"
android:background="#drawable/buttonclick"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:textSize="20sp"
></Button>
<TextView
android:id="#+id/browseby"
android:text="Browse by:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textStyle="bold"
android:textColor="#000000"
android:layout_marginLeft="10dp"
android:paddingTop="10dp"></TextView>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<Button
android:id="#+id/jobsbycity"
android:text="City"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:textColor="#FFFFFF"
android:background="#drawable/buttonclick"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:textStyle="bold"
android:textSize="15sp"
></Button>
<Button
android:id="#+id/jobsbytype"
android:text="Category"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:textColor="#FFFFFF"
android:background="#drawable/buttonclick"
android:layout_below="#id/jobsbycity"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textStyle="bold"
android:layout_marginTop="5dp"
android:textSize="15sp"
></Button>
<TextView
android:id="#+id/signin"
android:text="Signed in as"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:textColor="#000000"
android:layout_centerInParent="true"
android:gravity="center_horizontal"
android:layout_below="#id/jobsbytype"
android:paddingTop="10dp"></TextView>
<TextView
android:id="#+id/signinas"
android:text="mail_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:layout_centerInParent="true"
android:textColor="#000000"
android:gravity="center_horizontal"
android:layout_below="#id/signin"
android:paddingTop="5dp"></TextView>
<TextView
android:id="#+id/logout"
android:text="Sign out"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13sp"
android:gravity="center_vertical"
android:textColor="#000000"
android:layout_below="#id/signinas"
android:layout_centerInParent="true"
android:layout_marginTop="20dp"
android:textStyle="bold" ></TextView>
</RelativeLayout>
</LinearLayout>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
</ScrollView>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/tabbarbottom"
android:layout_gravity="bottom"
>
<Button
android:id="#+id/jobs"
android:text="About Us"
android:layout_width="100dp"
android:layout_height="fill_parent"
android:textColor="#drawable/white"
android:background="#android:color/transparent"
android:layout_alignParentBottom="true"
android:textStyle="bold"
android:textSize="12.5sp"
></Button>
<Button
android:id="#+id/aboutus"
android:text="Value"
android:layout_width="100dp"
android:layout_height="fill_parent"
android:textColor="#drawable/white"
android:layout_toRightOf="#id/jobs"
android:background="#android:color/transparent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_alignParentBottom="true"
android:layout_marginLeft="10dp"
android:textStyle="bold"
android:textSize="12.5sp"
></Button>
<Button
android:id="#+id/benefits"
android:text="History"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="#drawable/white"
android:layout_toRightOf="#id/aboutus"
android:background="#android:color/transparent"
android:layout_centerVertical="true"
android:layout_alignParentBottom="true"
android:textStyle="bold"
android:textSize="12.5sp"
></Button>
</RelativeLayout>
</LinearLayout>
I want to place the relative layout (last relative layout which having 3 buttons it, after scrollview ) at the bottom my screen. but its not happening
what to do??
Edited: The happening is i statically placed the relative layout by specifying padding, when running in portrait mode i made it fix at bottom but when i changed to landscape its not at bottom. How to place relativelayout in bottom in either cases??
Thanks
Add following line to your Relative layout
android:layout_alignParentBottom="true"
This must be work.
Happy coding.
Here the solution I tested and which works :
<?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">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="100dp"
android:layout_weight="1.0" android:fadingEdge="none">
...
</ScrollView>
<RelativeLayout android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="60dip"
android:background="#drawable/tabbarbottom">
<Button android:id="#+id/jobs" android:text="About Us"
android:layout_width="100dp" android:layout_height="fill_parent"
...></Button>
<Button android:id="#+id/aboutus" android:text="Value"
android:layout_width="100dp" android:layout_height="fill_parent"
...></Button>
<Button android:id="#+id/benefits" android:text="History"
android:layout_width="fill_parent" android:layout_height="fill_parent" ...></Button>
</RelativeLayout>
</LinearLayout>
The first LinearLayout should have layout_height="fill_parent".
This way it takes up the whole screen.
The ScrollView should have a
small fixed height, and an extra android:layout_weight="1.0" : it
will take up whatever space is remaining.
The RelativeLayout should
have a fixed height (it will always take up the same space at the
bottom of the screen), and the Buttons inside of it should have
layout_height="fill_parent" (to have the same height as the
RelativeLayout).
Make parent layout as relative layout. layout which contain button put that on bottom using
android:layout_alignParentBottom="true"
This will work
In the ScrollView
android:fillViewport="false"
#Udaykiran Hey Your Code for XMl is ok please check here i put your code with some change and i found only one change in this Relative Layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
please change this than try
here is xml with with out resources
<?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="wrap_content" android:orientation="vertical">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="430dp"
android:fadingEdge="none">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:background="#drawable/splash_screen_large_long_land"
android:orientation="vertical" android:id="#+id/searchjobslayout">
<ImageView android:id="#+id/homeimage_one"
android:layout_height="wrap_content" android:layout_gravity="center_horizontal"
android:layout_width="fill_parent"></ImageView>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="vertical">
<TextView android:id="#+id/keywords" android:text="Search by keyword:"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="14sp" android:textStyle="bold" android:textColor="#000000"
android:layout_marginLeft="10dp"></TextView>
<EditText android:id="#+id/keywordsedit" android:hint=" Enter KeyWords"
android:layout_width="fill_parent" android:layout_height="32dp"
android:layout_marginLeft="10dp" android:layout_marginRight="10dp"
android:textSize="14sp" android:layout_marginTop="5dp"
android:textColorHint="#FFFFFF" android:paddingLeft="10dp"
android:textColor="#000000"></EditText>
<Button android:id="#+id/search" android:text="Search"
android:layout_width="fill_parent" android:layout_height="35dp"
android:textColor="#FFFFFF" android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" android:layout_marginTop="5dp"
android:textSize="20sp"></Button>
<TextView android:id="#+id/browseby" android:text="Browse by:"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="14sp" android:textStyle="bold" android:textColor="#000000"
android:layout_marginLeft="10dp" android:paddingTop="10dp"></TextView>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button android:id="#+id/jobsbycity" android:text="City"
android:layout_width="fill_parent" android:layout_height="30dp"
android:textColor="#FFFFFF" android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" android:layout_marginTop="5dp"
android:textStyle="bold" android:textSize="15sp"></Button>
<Button android:id="#+id/jobsbytype" android:text="Category"
android:layout_width="fill_parent" android:layout_height="30dp"
android:textColor="#FFFFFF" android:layout_below="#id/jobsbycity"
android:layout_marginLeft="10dp" android:layout_marginRight="10dp"
android:textStyle="bold" android:layout_marginTop="5dp"
android:textSize="15sp"></Button>
<TextView android:id="#+id/signin" android:text="Signed in as"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="12sp" android:textColor="#000000"
android:layout_centerInParent="true" android:gravity="center_horizontal"
android:layout_below="#id/jobsbytype" android:paddingTop="10dp"></TextView>
<TextView android:id="#+id/signinas" android:text="mail_id"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="12sp" android:layout_centerInParent="true"
android:textColor="#000000" android:gravity="center_horizontal"
android:layout_below="#id/signin" android:paddingTop="5dp"></TextView>
<TextView android:id="#+id/logout" android:text="Sign out"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="13sp" android:gravity="center_vertical"
android:textColor="#000000" android:layout_below="#id/signinas"
android:layout_centerInParent="true" android:layout_marginTop="20dp"
android:textStyle="bold"></TextView>
</RelativeLayout>
</LinearLayout>
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_gravity="bottom">
<Button android:id="#+id/jobs" android:text="About Us"
android:layout_width="100dp" android:layout_height="fill_parent"
android:background="#android:color/transparent"
android:layout_alignParentBottom="true" android:textStyle="bold"
android:textSize="12.5sp"></Button>
<Button android:id="#+id/aboutus" android:text="Value"
android:layout_width="100dp" android:layout_height="fill_parent"
android:layout_toRightOf="#id/jobs" android:background="#android:color/transparent"
android:layout_centerHorizontal="true" android:layout_centerVertical="true"
android:layout_alignParentBottom="true" android:layout_marginLeft="10dp"
android:textStyle="bold" android:textSize="12.5sp"></Button>
<Button android:id="#+id/benefits" android:text="History"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_toRightOf="#id/aboutus" android:background="#android:color/transparent"
android:layout_centerVertical="true"
android:layout_alignParentBottom="true" android:textStyle="bold"
android:textSize="12.5sp"></Button>
</RelativeLayout>