How to configure GridLayout to take most of the horizontal screen space - android-layout

I am trying to mimic this sort of design on android using GridLayout:
I think I have most of it done using the below code:
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:columnCount="8"
android:rowCount="4"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:background="#drawable/rounded">
<TextView
android:layout_gravity="center_horizontal"
android:text="Some Text Here"
android:textStyle="bold"
android:textColor="#000000"
android:textSize="30dp"
android:textAlignment="center"
android:layout_columnSpan="8"
android:paddingBottom="10dp"
/>
<TextView
android:text="16"
android:textStyle="bold"
android:paddingRight="70dp"
android:textColor="#000000"
android:textSize="18dp"
android:paddingLeft="10dp"
android:paddingBottom="5dp"/>
<TextView
android:text="27"
android:textStyle="bold"
android:paddingRight="70dp"
android:textSize="18dp"
android:textColor="#000000"/>
<TextView
android:text="52"
android:textStyle="bold"
android:layout_columnSpan="6"
android:textSize="18dp"
android:paddingRight="10dp"
android:textColor="#000000"/>
<TextView
android:text="Text 1"
android:paddingRight="20dp"
android:paddingLeft="10dp"
android:textSize="18dp"
android:textColor="#ff565656"
android:paddingBottom="10dp"/>
<TextView
android:text="Text 2"
android:paddingRight="20dp"
android:textSize="18dp"
android:textColor="#ff565656"/>
<TextView
android:text="Text 3"
android:textColor="#ff565656"
android:textSize="18dp"
android:paddingRight="10dp"/>
</GridLayout>
However, when I run it in my emulator it looks like this:
Notice that it is leaving too much space on the right and the left.
Question
How can I configure the grid layout so it takes up most of the screen on right and left of it (just like in the sample above).
How can I change the screen background color - Right now it is black, I'd like to change it to another color.

For GridLayout, replace this...
android:layout_width="wrap_content"
with...
android:layout_width="fill_parent"
as follows...
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:columnCount="8"
android:rowCount="4"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:background="#drawable/rounded">

#Anthony - You are not using the power and the essence of GridLayout in the code written. As you have manually allotted paddings to the views in order to make them appear in the first screen, which is very much possible with any other layout as well. Like below.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="2"
android:text="Some Text Here"
android:textAppearance="?android:attr/textAppearanceLarge" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<TextView
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="16"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="17"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="18"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<TextView
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Text1"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Text2"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="Text3"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
And, GridLayout is about rows and columns. So if you want your Views to be placed such that and to use it to fuller, you can supply the row as well as column position where you view should be placed in which order and its other properties will add up to it. Here is a link.
Try this out and I am sure you will understand it much better. Happy coding. :)

Related

Make all RelativeLayout same size

I have multiple RelativeLayout inside LinearLayout. Inside my RelativeLayout it has 2 TextView. The value inside the TextView changes for example the date today.
What I'm aiming to do is that regardless of how long the value of my TextView is, whoever has the higher height the rest of the RelativeLayout's size will be the same as the higher height.
Here's my xml
<LinearLayout
android:id="#+id/llbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_weight="1">
<RelativeLayout
android:id="#+id/today"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#color/lightblue">
<TextView
android:id="#+id/day"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:drawablePadding="5dp"
android:drawableStart="#drawable/calendar"
android:padding="5dp"
android:textColor="#color/white"
android:textSize="16dp"
android:textStyle="bold" />
<TextView
android:id="#+id/monthyear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/day"
android:gravity="center"
android:padding="5dp"
android:textAllCaps="true"
android:textColor="#color/white"
android:textSize="12dp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/outbox_rl"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#color/lightblue">
<TextView
android:id="#+id/no_of_outbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:drawablePadding="5dp"
android:drawableStart="#drawable/outbox"
android:padding="5dp"
android:textColor="#color/white"
android:textSize="16dp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/no_of_outbox"
android:gravity="center"
android:padding="5dp"
android:text="#string/outbox"
android:textAllCaps="true"
android:textColor="#color/white"
android:textSize="12dp"
android:textStyle="bold" />
</RelativeLayout>
</LinearLayout>
Currently it looks like this
but I want Outbox box to be the same height as the Today box.
Thank you in advance.
You have to assign the height of both the Today and Outbox RelativeLayout to match_parent instead of wrap_content.
<RelativeLayout
android:id="#+id/today"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#color/lightblue">
<TextView
android:id="#+id/day"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:drawablePadding="5dp"
android:drawableStart="#drawable/calendar"
android:padding="5dp"
android:textColor="#color/white"
android:textSize="16dp"
android:textStyle="bold" />
<TextView
android:id="#+id/monthyear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/day"
android:gravity="center"
android:padding="5dp"
android:textAllCaps="true"
android:textColor="#color/white"
android:textSize="12dp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/outbox_rl"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#color/lightblue">
<TextView
android:id="#+id/no_of_outbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:drawablePadding="5dp"
android:drawableStart="#drawable/outbox"
android:padding="5dp"
android:textColor="#color/white"
android:textSize="16dp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/no_of_outbox"
android:gravity="center"
android:padding="5dp"
android:text="#string/outbox"
android:textAllCaps="true"
android:textColor="#color/white"
android:textSize="12dp"
android:textStyle="bold" />
</RelativeLayout>
Just make sure that the height of the parent layout is set to wrap_content which you already have done in your code. :)
OUTPUT
With longer today text
With longer outbox text
With both with same text length
Try to replace android:layout_weight="1" to android:weightSum="3" and add android:orientation="horizontal" in LinearLayout and fix the height of RelativeLayout

Horiz LinearLayout containing two spinners not displayed

I'm trying to assemble an Android display consisting of a seekBar at the bottom surmounted by two adjacent spinners contained in a horizontal linearLayout. It looks okay in the design view, but the two spinners fail to display in the running app.
I appreciate any help to isolate my stupidity.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.android.rotiferian.MainActivity">
<!-- view for AdMob Banner Ad -->
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
ads:adSize="BANNER"
ads:adUnitId="#string/banner_ad_unit_id" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="false"
android:layout_alignParentStart="true"
android:layout_marginStart="0dp"
android:layout_marginBottom="10dp"
android:layout_alignParentEnd="false"
android:id="#+id/linearLayout"
android:layout_marginEnd="0dp"
android:layout_above="#+id/seekBar"
android:visibility="visible">
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/spinnerLeft"
android:gravity="start"
style="#style/Base.Animation.AppCompat.DropDownUp"
android:popupBackground="#ff2f50"
android:background="#ce243f"
android:layout_weight="1"
android:visibility="visible"
android:layout_gravity="start" />
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/spinnerRight"
android:gravity="end"
style="#style/Base.Animation.AppCompat.DropDownUp"
android:background="#ff4eff2f"
android:popupBackground="#ff4eff2f"
android:paddingStart="20dp"
android:layout_weight="1"
android:visibility="visible"
android:layout_gravity="end" />
</LinearLayout>
<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/seekBar"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:splitTrack="false"
android:max="1000"
android:background="#00000000"
android:backgroundTint="#ff000000"/>

Android ListActivity doesn't center the items

I have a ListActivity which displays an image and some text.
The imageView has a fixed size and I want to center the list horizontally.
After endless tries, I set any gravity to center_horinzontal, but nothing works.
The list is shown over the whole screen, as I can see by the scrollbar on the right side. But my frame remains on the left side.
In the adapter class, which entends ArrayAdapter, I even tried to set the gravity during runtime, but when I try to manipulate then basic LinearLayout, I get the error:
"java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams"
My attempt to change gravity in the method getView() which throws the error:
LinearLayout layout = (LinearLayout) rowView.findViewById(R.id.bootsFrameLayout);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
params.gravity = Gravity.CENTER_HORIZONTAL;
layout.setLayoutParams(params);
The list row is designed in a layout file:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/bootsFrameLayout"
android:layout_width="300dp"
android:layout_height="250dp"
android:layout_gravity="center_horizontal"
android:layout_marginEnd="20dp"
android:layout_marginStart="20dp"
android:background="#drawable/card_blank2"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:id="#+id/bootsName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="TextView"
android:textAppearance="#style/BootNameStyle" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginEnd="30dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginStart="30dp" >
<ImageView
android:id="#+id/bootImage"
android:layout_width="240dp"
android:layout_height="180dp"
android:layout_gravity="center_horizontal"
android:scaleType="centerCrop"
android:src="#drawable/test_boot" />
<TextView
android:id="#+id/textWatchList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:background="#color/gray_transparent"
android:gravity="end"
android:lines="2"
android:text="#string/watchlist"
android:textAppearance="#style/BootWatchListStyle" />
<ProgressBar
android:id="#+id/bootProgressbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:visibility="invisible" />
</FrameLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="25dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginStart="25dp" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/bootMasse"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="70"
android:text="TextView"
android:textAppearance="#style/BootInfoStyle" />
<TextView
android:id="#+id/bootBaujahr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="30"
android:gravity="right"
android:text="TextView"
android:textAppearance="#style/BootInfoStyle" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/bootLand"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="70"
android:text="TextView"
android:textAppearance="#style/BootInfoStyle" />
<TextView
android:id="#+id/bootPreis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="30"
android:gravity="right"
android:text="TextView"
android:textAppearance="#style/BootPreisStyle" />
</TableRow>
</TableLayout>
The ListView is defined here:
<ListView
android:id="#android:id/list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:layout_marginEnd="12dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginStart="12dp"
android:layout_weight="8" >
</ListView>
The activity occupies the whole screen, as it should do.
But although there is place enough, the frame won't center.
Any ideas?

Android relative layout doesn't scroll

I have a relative layout in my xml file inside which I have another relative layout which has all my content. My Inner relative layout is loaded with content that comes from my database.
Also I have a edittext and button at bottom for adding comments.
Now the problem is that my inner relative layout doesn't scroll when the content is more but all the contents get hidden inside the bottom edit text and button.
Here is my xml.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/BG"
android:paddingTop="10dp" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#FFFFFF"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingBottom="15dp"
android:scrollbars="vertical" >
<TextView
android:id="#+id/discTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginTop="20dp"
android:text="Title"
android:textColor="#77d3f1"
android:textSize="18sp" />
<TextView
android:id="#+id/discCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/discTitle"
android:layout_below="#+id/discTitle"
android:layout_marginTop="20dp"
android:text="Category"
android:textColor="#77d3f1"
android:textSize="14sp" />
<TextView
android:id="#+id/discDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/discCategory"
android:layout_below="#+id/discCategory"
android:layout_marginTop="20dp"
android:text="Decsription"
android:textColor="#908484"
android:textSize="16sp" />
<TextView
android:id="#+id/discTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/discDescription"
android:layout_below="#+id/discDescription"
android:layout_marginTop="20dp"
android:text="yyyy mm dd hh:mm:ss"
android:textSize="10sp" />
</RelativeLayout>
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginRight="60dp"
android:background="#drawable/commentbg"
android:ems="10"
android:hint="Type a comment..."
android:inputType="textMultiLine"
android:minHeight="40dp"
android:paddingLeft="10dp"
android:textStyle="italic" >
<requestFocus />
</EditText>
<Button
android:id="#+id/button1"
android:layout_width="61dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="#drawable/commentbg"
android:minHeight="40dp"
android:text="Send" />
</RelativeLayout>
Now I want the inner relative layout’s height to occupy the whole screen and has to be
scrollable when content is more.Have a look at the image below.
Thanks in advance.
Wrap it in ScrollView
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/scroll_view_layout">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#FFFFFF"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingBottom="15dp"
android:scrollbars="vertical" >
<TextView
android:id="#+id/discTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginTop="20dp"
android:text="Title"
android:textColor="#77d3f1"
android:textSize="18sp" />
<TextView
android:id="#+id/discCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/discTitle"
android:layout_below="#+id/discTitle"
android:layout_marginTop="20dp"
android:text="Category"
android:textColor="#77d3f1"
android:textSize="14sp" />
<TextView
android:id="#+id/discDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/discCategory"
android:layout_below="#+id/discCategory"
android:layout_marginTop="20dp"
android:text="Decsription"
android:textColor="#908484"
android:textSize="16sp" />
<TextView
android:id="#+id/discTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/discDescription"
android:layout_below="#+id/discDescription"
android:layout_marginTop="20dp"
android:text="yyyy mm dd hh:mm:ss"
android:textSize="10sp" />
</RelativeLayout>
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginRight="60dp"
android:background="#drawable/commentbg"
android:ems="10"
android:hint="Type a comment..."
android:inputType="textMultiLine"
android:minHeight="40dp"
android:paddingLeft="10dp"
android:textStyle="italic" >
<requestFocus />
</EditText>
<Button
android:id="#+id/button1"
android:layout_width="61dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="#drawable/commentbg"
android:minHeight="40dp"
android:text="Send" />
</RelativeLayout>
</ScrollView>
To scroll content you need to add ScrollView. ScrollView will be parent of the layout that you want to scroll.
http://developer.android.com/reference/android/widget/ScrollView.html

MarginTop between radio buttons for Different Screen Densities in Android

Im trying to make a layout for a survey question, it works fine on my device but the margin between the radio button text decreases on a better screen resolution device.
I have tried creating different DIMENS it works but I'm not sure how to scale the margin based on different sizes.
Kindly suggests what screen size values-swXXX folder I need to create and what should be the scaling factor of the DIMEN I have defined.
Thanks
enter code here
<?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" >
<TextView
android:id="#+id/tv_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="How often do you use it?"
android:textSize="15sp" />
<RadioGroup
android:id="#+id/rg_1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tv_1"
android:layout_below="#+id/tv_1" >
<RadioButton
android:id="#+id/rb_once"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="15dp"
android:button="#drawable/radio_btn"
android:checked="true"
android:text="Once" />
<RadioButton
android:id="#+id/rb_daily"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/rb_once"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:button="#drawable/radio_btn"
android:text="Daily" />
<RadioButton
android:id="#+id/rb_weekly"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/rb_daily"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:button="#drawable/radio_btn"
android:text="Weekly" />
<RadioButton
android:id="#+id/rb_monthly"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/rb_weekly"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:button="#drawable/radio_btn"
android:text="Monthly" />
</RadioGroup>
<ImageView
android:id="#+id/fb_share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_margin="10dp"
android:src="#drawable/facebook_share" />
<ImageView
android:id="#+id/history"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignTop="#+id/fb_share"
android:layout_marginLeft="10dp"
android:src="#drawable/history" />
<ImageView
android:id="#+id/info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/fb_share"
android:layout_marginRight="10dp"
android:src="#drawable/info" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/fb_share"
android:layout_below="#+id/rg_1"
android:layout_centerHorizontal="true" >
<Button
android:id="#+id/send"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:background="#drawable/red_btn"
android:fontFamily="Roboto-Italic"
android:text="SAVE"
android:textColor="#ffffff" />
</RelativeLayout>
</RelativeLayout>
You need to create values-swXXXX folders wrt devices you are targetting for. i.e If you are targetting for a tablet with minimum width of 600, then you need to create values-sw600 and so on.
In layout file, change declaration of RadioButton as below:
<RadioButton
android:id="#+id/rb_once"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/left_margin"
android:layout_marginTop="#dimen/top_margin"
android:button="#drawable/radio_btn"
android:checked="true"
android:text="Once" />
And maintain dimen.xml specific to each targeted dimension under values-swXXXX with dimension keys having same name but values corresponding to respective dimension. Ex:
values/
<dimen name="left_margin">5dp</dimen>
<dimen name="left_margin">10dp</dimen>
values-sw600/
<dimen name="left_margin">20dp</dimen>
<dimen name="left_margin">40dp</dimen>

Resources