Here what I am doing is , I want to show the seekbar running in between the RangeSeekBar (between the selected range). For that, I want to place these two seekbars at one position.
I don't know how to do that. I have tried RelativeLayout and FrameLayout but nothing happened.
Thank you.
activity_play.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity">
<SeekBar
android:id="#+id/pSeekBar"
android:layout_width="match_parent"
android:layout_height="37dp" />
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#android:drawable/screen_background_light"
android:orientation="vertical"
android:padding="10dip">
<TextView
android:id="#+id/selectedfile"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="middle"
android:gravity="center_horizontal"
android:singleLine="true"
android:text="Not file selected"
android:textColor="#android:color/black" />
<com.yahoo.mobile.client.android.util.rangeseekbar.RangeSeekBar
android:id="#+id/rangeSeekBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:max="100"
android:paddingBottom="10dip"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#android:drawable/screen_background_light"
android:gravity="center"
android:orientation="horizontal">
<EditText
android:id="#+id/MinEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageButton
android:id="#+id/prev"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_media_previous" />
<ImageButton
android:id="#+id/play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_media_play" />
<ImageButton
android:id="#+id/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_media_next" />
<EditText
android:id="#+id/MaxEdiText"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
u can use this library its hard to write it yourself
https://github.com/syedowaisali/crystal-range-seekbar
Related
I made custom dialog in my app and it looks like this:
And "TEXT" is simply TextView inside a ScrollView. Height of everything is "wrap_content" to match the content and don't match the whole screen unnecessary. And everything is ok untill the text is too big and I have to scroll. Then my down part of dialog is gone and now dialog looks like this:
How can I make this work well to be like this all the time?
Here is the code of my custom dialog layout:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="0dp"
tools:context="com.baddevelopergames.taboopremiumrebuild.DialogActivity">
<ImageView
android:background="#drawable/ramkahg"
android:alpha="0.8"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:text="TEXT"
android:textColor="#000000"
android:background="#019d92"
android:alpha="0.8"
android:id="#+id/d1_infoTextView"
android:textSize="15sp"
android:gravity="center"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</ScrollView>
<LinearLayout
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:background="#019d92"
android:alpha="0.8"
android:gravity="center"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:text="BUTTON 1"
android:id="#+id/d1_leftButton"
android:layout_weight="1"
android:layout_gravity="center_horizontal"
android:layout_width="0dp"
android:layout_height="wrap_content" />
<Button
android:text="BUTTON 2"
android:id="#+id/d1_rightButton"
android:layout_weight="1"
android:layout_gravity="center_horizontal"
android:layout_width="0dp"
android:layout_height="wrap_content" />
</LinearLayout>
<ImageView
android:background="#drawable/ramkahd"
android:alpha="0.8"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
If you want the buttons to be always on the bottom, and TEXT always above, I think you should use a RelativeLayout instead. Try with these xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="0dp"
tools:context="com.baddevelopergames.taboopremiumrebuild.DialogActivity">
<ImageView
android:background="#drawable/ramkahg"
android:alpha="0.8"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ScrollView
android:layout_above="#+id/buttons"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<TextView
android:text="TEXT"
android:textColor="#000000"
android:background="#019d92"
android:alpha="0.8"
android:id="#+id/d1_infoTextView"
android:textSize="15sp"
android:gravity="center"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</ScrollView>
<LinearLayout
android:id="#+id/buttons"
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:background="#019d92"
android:alpha="0.8"
android:gravity="center"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button
android:text="BUTTON 1"
android:id="#+id/d1_leftButton"
android:layout_weight="1"
android:layout_gravity="center_horizontal"
android:layout_width="0dp"
android:layout_height="wrap_content" />
<Button
android:text="BUTTON 2"
android:id="#+id/d1_rightButton"
android:layout_weight="1"
android:layout_gravity="center_horizontal"
android:layout_width="0dp"
android:layout_height="wrap_content" />
</LinearLayout>
</RelativeLayout>
<ImageView
android:background="#drawable/ramkahd"
android:alpha="0.8"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
I have this layout xml file:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<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="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity">
<TextView
android:layout_marginTop="40dp"
android:id="#+id/emalLbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="#string/test" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/testTxtLay"
android:layout_marginTop="10dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/emalLbl"
android:orientation="horizontal"
android:padding="10dp"
android:weightSum="1">
<EditText
android:id="#+id/testTxt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:background="#drawable/edit_text_design" />
</LinearLayout>
<TextView
android:layout_marginTop="60dp"
android:id="#+id/reminderLbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/testTxtLay"
android:layout_centerHorizontal="true"
android:text="#string/reminder" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_marginTop="10dp"
android:id="#+id/reminderTxtLay"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/reminderLbl"
android:orientation="horizontal"
android:padding="10dp"
android:weightSum="1">
<EditText
android:id="#+id/reminderTxt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:lines="2"
android:background="#drawable/edit_text_design" />
</LinearLayout>
<View
android:id="#+id/spacer"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="#id/reminderTxtLay"
android:layout_centerHorizontal="true" />
<Button
android:layout_marginTop="200dp"
android:id="#+id/pickDateBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/reminderTxtLay"
android:layout_toLeftOf="#+id/spacer"
android:onClick="showDatePickerDialog"
android:text="#string/datePickerBtnTxt" />
<Button
android:id="#+id/pickTimeBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/pickDateBtn"
android:layout_alignParentRight="true"
android:layout_toRightOf="#+id/pickDateBtn"
android:onClick="showTimePickerDialog"
android:text="#string/pickTimeBtn" />
<View
android:id="#+id/spacerTxt"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="#id/reminderTxtLay"
android:layout_centerHorizontal="true" />
<EditText
android:layout_marginTop="15dp"
android:id="#+id/selectedDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/spacerTxt"
android:layout_below="#id/pickDateBtn"
android:layout_toLeftOf="#+id/spacerTxt" />
<EditText
android:id="#+id/selectedTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/selectedDate"
android:layout_below="#id/pickTimeBtn"
android:layout_toRightOf="#+id/selectedDate" />
<Button
android:id="#+id/submitBtn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:onClick="submitData"
android:text="#string/submitBtn" />
</RelativeLayout>
</ScrollView>
This is the custom design for 7 inch tablets, placed in res\layout-sw600dp
Anyways in the android studio landscape preview it seems just fine:
But in the emulator something is going wrong and here is how it looks strange. What I mean is that the submit button is not on the bottom and the pickDate and pickTime buttons are at the bottom of the layout.
I know that I'm missing a basic point here, but as an android developer, I'm not able to spot it.
Can you give me a push?
Here is a complete way to do what you seem to try accomplish. You don't need to create any Views for "spaces" etc. You only need to add margin or padding to either side of your views to make it move away from another view.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<LinearLayout
android:id="#+id/linear_wrapper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_horizontal"
>
<TextView
android:layout_marginTop="40dp"
android:id="#+id/emalLbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/test" />
<EditText
android:id="#+id/testTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edit_text_design" />
<TextView
android:layout_marginTop="60dp"
android:id="#+id/reminderLbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/reminder" />
<EditText
android:id="#+id/reminderTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="2"
android:background="#drawable/edit_text_design" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="200dp"
>
<Button
android:id="#+id/pickDateBtn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="showDatePickerDialog"
android:text="#string/datePickerBtnTxt" />
<Button
android:id="#+id/pickTimeBtn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="showTimePickerDialog"
android:text="#string/pickTimeBtn" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/selectedDate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<EditText
android:id="#+id/selectedTime"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
<Button
android:id="#+id/submitBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_below="#+id/linear_wrapper"
android:onClick="submitData"
android:text="#string/submitBtn" />
</RelativeLayout>
you can place 2 buttons next to each other!
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp"
android:weightSum="1">
<Button
android:id="#+id/btn1"
android:layout_width="wrap_content"
android:gravity="left"
android:layout_height="wrap_content"
android:lines="2" />
<Button
android:id="#+id/btn2"
android:layout_width="fill_parent"
android:gravity="right"
android:layout_height="wrap_content" />
</LinearLayout>
So I am having problems with some XML layout coding... I am supposed to replicate this image
but so far I seem to be only able to get this far and the checkout button refuses to stay to the right even when I do use android:gravity="right" to float right within its container... :/
This is the code I have so far:
<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="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".CartActivity" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:text="Shopping Cart"
android:background="#android:color/holo_blue_dark" />
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#android:color/holo_blue_light"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Subtotal:" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#800000"
android:text="£???" />
<Button
android:id="#+id/checkout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="Checkout" >
</Button>
</LinearLayout>
</LinearLayout>
use a android:weightSum="3" for your inner
Layout with the three elements, and after that,
android:layout_weight="1" to each view
this will make the views to hold 1/3 of the available space
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#android:color/holo_blue_light"
android:weightSum="3"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Subtotal:"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#800000"
android:text="£???"
android:layout_weight="1" />
<Button
android:id="#+id/checkout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="Checkout"
android:layout_weight="1">
</Button>
</LinearLayout>
EDIT fill_parent is deprecated use match_parent
Try to use a Relativelayout
<RelativeLayout
android:id="#+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Subtotal:" />
<TextView
android:id="#+id/textView2"
android:layout_toRightOf="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#800000"
android:text="£???" />
<Button
android:id="#+id/checkout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="Checkout" >
</Button>
</RelativeLayout>
I am trying to center the text in my TextView and Button. I currently have the following code:
<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="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#000000" >
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_weight="0.15"
android:layout_height="0dp"
android:gravity="center"
android:text="#string/CouponFinder"
android:textSize="30sp"
android:textColor="#FF0000"
android:typeface="monospace" />
<ImageView
android:id="#+id/couponImage"
android:layout_width="match_parent"
android:layout_weight="0.7"
android:layout_height="0dp"
android:src="#drawable/coupon" />
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_weight="0.15"
android:layout_height="0dp"
android:text="#string/continueButton"
android:textSize="30sp"
android:gravity="center"/>
</LinearLayout>
</RelativeLayout>
However, the text in the Button and TextView are to the right and hence some of the text is off the screen... I am also getting the following warning for my LinearLayout:
This LinearLayout layout or its RelativeLayout parent is possibly useless
Any help would be greatly appreciated!!
Try this
[<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.15"
android:gravity="center"
android:hint="asdasasdasdd"
android:text="adasdasdasd"
android:textAlignment="gravity"
android:textColor="#FFffff"
android:textSize="30sp"
android:typeface="monospace" />]
Try this,
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:context=".MainActivity" >
<ImageView
android:id="#+id/couponImage"
android:layout_width="wrap_content"
android:layout_weight="0.7"
android:layout_height="wrap_content"
android:src="#drawable/coupon" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView1"
android:gravity="center"
android:text="continueButton"
android:textSize="30sp" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:gravity="center_horizontal"
android:text="CouponFinder"
android:textColor="#FF0000"
android:textSize="30sp"
android:typeface="monospace" />
</RelativeLayout>
Try this..
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:background="#000000" >
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_weight="0.15"
android:layout_height="0dp"
android:gravity="center"
android:text="CouponFinder"
android:textSize="30sp"
android:textColor="#FF0000"
android:typeface="monospace" />
<ImageView
android:id="#+id/couponImage"
android:layout_width="match_parent"
android:layout_weight="0.7"
android:layout_height="0dp"
android:src="#drawable/icon" />
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_weight="0.15"
android:layout_height="0dp"
android:text="continueButton"
android:textSize="30sp"
android:gravity="center"/>
</LinearLayout>
You should make the RelativeLayout a LinearLayout, and get rid of the internal LinearLayout, unless you plan to make modifications and add more things inside the RelativeLayout and outside of the LinearLayout.
Try setting the layout-gravity on the items instead of gravity.
Hope this helps :)
Try this way:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.15"
android:gravity="center"
android:text="CouponFinder"
android:textColor="#FF0000"
android:textSize="30sp"
android:typeface="monospace" />
<ImageView
android:id="#+id/couponImage"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.7"
android:src="#drawable/icon" />
<Button
android:id="#+id/button1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.15"
android:gravity="center"
android:text="continueButton"
android:textSize="30sp" />
</LinearLayout>
The warning is because you are using only one LinearLayout as the Child View for RelativeLayout.So remove your RelativeLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#000000" >
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_weight="0.15"
android:layout_height="0dp"
android:gravity="center"
android:text="#string/CouponFinder"
android:textSize="30sp"
android:textColor="#FF0000"
android:typeface="monospace" />
<ImageView
android:id="#+id/couponImage"
android:layout_width="match_parent"
android:layout_weight="0.7"
android:layout_height="0dp"
android:text="#string/CouponFinder" />
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_weight="0.15"
android:layout_height="0dp"
android:text="#string/continueButton"
android:textSize="30sp"
android:gravity="center"/>
</LinearLayout>
Try the above data.I got this by the above data
What you've done is correct, but to see the changes, you just need to restart your IDE. I found the answer here.
I have a Relative Layout Containing following Views and Nested Relative Layouts. For Some devices there is a blank space left at the bottom of the screen. I want to equitably distribute the space to the nested views and viewgroups() to fill the Screen.
<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="fill_parent"
android:orientation="vertical"
android:background="#color/tdmubiobgd"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MasterActivity$DummySectionFragment" >
<Button
android:id="#+id/ScanButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="Scan" />
<ImageView
android:id="#+id/scan_adsView"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:layout_alignLeft="#id/ScanButton"
android:layout_alignParentTop="true"
android:scaleType="fitXY"
android:src="#drawable/ads" />
<RelativeLayout
android:id="#+id/scan_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/scan_adsView"
android:layout_below="#id/scan_adsView"
android:layout_marginTop="10px"
android:orientation="horizontal" >
<ImageView
android:id="#+id/Scan_Image"
android:layout_width="72px"
android:layout_height="72px"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/Scan_Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/Scan_Image"
android:text="Name"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<TextView
android:id="#+id/Scan_DName"
android:layout_width="80dip"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView3"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:gravity="right"
android:text="DName "
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold" />
<TextView
android:id="#+id/Scan_Sex"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/Scan_Name"
android:layout_toRightOf="#+id/Scan_Age"
android:text="Male"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/Scan_Age"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/Scan_Sex"
android:layout_alignBottom="#+id/Scan_Sex"
android:layout_alignLeft="#+id/Scan_Name"
android:text="30"
android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>
<ImageView
android:id="#+id/scan_level1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/scan_header"
android:layout_below="#+id/scan_header"
android:scaleType="fitXY"
android:src="#drawable/l1warning" />
<RelativeLayout
android:id="#+id/scan_master"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/scan_level"
android:layout_below="#id/scan_level1"
android:layout_marginTop="10px"
android:orientation="horizontal" >
<TextView
android:id="#+id/scan_mname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="MinionRush"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/scan_mdetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/scan_mname"
android:layout_below="#+id/scan_mname"
android:text="DoodlePlay"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/scan_period"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/scan_mdetails"
android:text="DartRace"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:id="#+id/scan_alarm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="20dp"
android:src="#drawable/alarm" />
</RelativeLayout>
<ImageView
android:id="#+id/scan_level2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/scan_master"
android:layout_below="#id/scan_master"
android:scaleType="fitXY"
android:layout_marginTop="10px"
android:src="#drawable/toempty" />
<Gallery
android:id="#+id/scan_gallery"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/scan_level2"
android:layout_marginTop="10px"
android:layout_alignParentLeft="true" />
<ImageView
android:id="#+id/faq"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/scan_gallery"
android:layout_centerHorizontal="true"
android:layout_marginTop="10px"
android:scaleType="fitXY"
android:src="#drawable/faq" />
</RelativeLayout>
Use the following :
<?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"
android:background="#ffffff">
<ImageView
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:src="#drawable/ic_launcher" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#556677">
</RelativeLayout>
<Gallery
android:id="#+id/gallery1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#664411"/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#997766">
</RelativeLayout>
</LinearLayout>
Hope this will help you....
use linear layout as your parent layout and give weights to all layouts.
Here is a XML for your question
<?xml version="1.0" encoding="utf-8"?>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/ic_launcher" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
</RelativeLayout>
<Gallery
android:id="#+id/gallery1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
</RelativeLayout>
use
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
orientation="vertical">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:src="#drawable/ic_launcher" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</RelativeLayout>
<Gallery
android:id="#+id/gallery1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</RelativeLayout>
</LinearLayout>
use linear layout and add
android:layout:weight="1"
in every tag..
if you want to use the Relative layout then,it is better that you should get the screen dimension and divide it into four, if you have four views
Refer this link for getting screen size