I have an adview which is needed to place between two imageview's.My layout is
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#color/white" >
<ImageView
android:id="#+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:background="#drawable/backwonde"
android:contentDescription="#string/app_name"
android:onClick="listt" />
<ImageView
android:id="#+id/previous"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="45dp"
android:layout_marginTop="10dp"
android:contentDescription="#string/app_name"
android:onClick="previous"
android:src="#drawable/left" />
<ImageView
android:id="#+id/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:contentDescription="#string/app_name"
android:onClick="next"
android:src="#drawable/right" />
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/next"
ads:adSize="BANNER"
ads:adUnitId="MY PUB ID"
ads:loadAdOnCreate="true" />
<ImageView
android:id="#+id/imm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/list"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:contentDescription="#string/app_name" />
<ImageView
android:id="#+id/imm2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imm"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:contentDescription="#string/app_name" />
<TextView
android:id="#+id/stext1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imm2"
android:layout_marginLeft="10dp"
android:layout_marginTop="30dp"
android:text="#string/Tit"
android:textColor="#color/DodgerBlue"
android:textSize="18dp"
android:textStyle="bold"
android:typeface="sans" />
<TextView
android:id="#+id/dtext1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/stext1"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:lineSpacingExtra="0.1dp"
android:textColor="#color/black"
android:textSize="15dp"
android:textStyle="normal"
android:typeface="serif" />
<TextView
android:id="#+id/stext2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/dtext1"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="#string/loc"
android:textColor="#color/DodgerBlue"
android:textSize="18dp"
android:textStyle="bold"
android:typeface="sans" />
<TextView
android:id="#+id/dtext2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/stext2"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:lineSpacingExtra="0.1dp"
android:textColor="#color/black"
android:textSize="15dp"
android:textStyle="normal"
android:typeface="serif" />
<TextView
android:id="#+id/stext3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/dtext2"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="#string/hist"
android:textColor="#color/DodgerBlue"
android:textSize="18dp"
android:textStyle="bold"
android:typeface="sans" />
<WebView
android:id="#+id/webview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/stext3"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="6dp"
android:background="#color/white" />
</RelativeLayout>
I need the ad between the Imageview's "next" and "imm".I have tried using the attribute layout below but it gives me circular dependency error.In which way i can achieve it.
Any suggestions are appreciated.
Thanks in advance.
Related
I am trying to line up the text and images next to each other in a perfect line but cant quite get it center.
As you see with the image it's almost center next to each other but not perfectly what am I missing
<?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:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" >
<TextView
android:id="#+id/textView1"
android:textSize="14dp"
android:textStyle="bold"
android:gravity="center_vertical"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<ImageView
android:id="#+id/imageView1"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/textView1"
android:layout_gravity="center_vertical|right"
android:gravity="center_vertical|right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/image_ls"
/>
<TextView
android:id="#+id/textView2"
android:textSize="14dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:textStyle="bold"
android:layout_toRightOf="#+id/imageView1"
android:layout_gravity="center_vertical|right"
android:gravity="center_vertical|right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
/>
<ImageView
android:id="#+id/imageView2"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/textView2"
android:layout_gravity="center_vertical|right"
android:gravity="center_vertical|right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/image_ls"
/>
<TextView
android:id="#+id/textView3"
android:layout_toRightOf="#+id/imageView2"
android:layout_gravity="center_vertical|right"
android:gravity="center_vertical|right"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:textSize="14dp"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
/>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="10dp">
<TextView
android:id="#+id/textView1"
android:textSize="14dp"
android:textStyle="bold"
android:gravity="center_vertical"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<ImageView
android:id="#+id/imageView1"
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="#drawable/image_ls" />
<TextView
android:id="#+id/textView2"
android:textSize="14dp"
android:layout_marginLeft="5dp"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="TextView" />
<ImageView
android:id="#+id/imageView2"
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="#drawable/image_ls" />
<TextView
android:id="#+id/textView3"
android:textSize="14dp"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="TextView" />
</LinearLayout>
Try This 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:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" >
<TextView
android:id="#+id/textView1"
android:textSize="14dp"
android:textStyle="bold"
android:gravity="center"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<ImageView
android:id="#+id/imageView1"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/textView1"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/image_ls"
/>
<TextView
android:id="#+id/textView2"
android:textSize="14dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:textStyle="bold"
android:layout_toRightOf="#+id/imageView1"
android:layout_centerVertical="true"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
/>
<ImageView
android:id="#+id/imageView2"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/textView2"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/image_ls"
/>
<TextView
android:id="#+id/textView3"
android:layout_toRightOf="#+id/imageView2"
android:layout_centerVertical="true"
android:gravity="center_vertical|right"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:textSize="14dp"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
/>
</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:gravity="center" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:text="TextView"
android:textSize="14dp"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical|right"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:text="TextView"
android:textSize="14dp"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:gravity="center_vertical|right"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:text="TextView"
android:textSize="14dp"
android:textStyle="bold" />
</LinearLayout>
Try this:
Use LinearLayout to fix android widgets in vertical or horizontal.
<?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:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textSize="14dp"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textSize="14dp"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:src="#drawable/ic_launcher" />
I've finished my app, and it looks great on my Nexus One emulator (400x800 Screen) However while testing the app, I found out that it doesn't scale that well on larger displays. Is there anything I can fix in my layout to fix scaling issues?
*Note, one of the testers of my App was using an LG G3 (2560x1440) screen, and a lot of the elements didn't fill up the screen like they do in my emulator.
My screenshot is below, and here is my layout file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="#+id/rlmain"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#bbcde3"
android:orientation="vertical" >
<GridLayout
android:id="#+id/gridLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#e3e3e3"
android:columnCount="2"
android:gravity="right"
android:orientation="horizontal" >
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-6005267993787158/4274166222"
ads:loadAdOnCreate="true" >
</com.google.ads.AdView>
</GridLayout>
<Space
android:layout_width="match_parent"
android:layout_height="12sp" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView2"
android:layout_below="#+id/gridLayout1"
android:layout_marginTop="20dp"
android:text="#string/rye"
android:textColor="#888888"
android:textSize="19sp" />
<RatingBar
android:id="#+id/ratingBar1"
style="#style/circleRatingBar"
android:layout_width="wrap_content"
android:layout_height="47dp"
android:layout_alignLeft="#+id/textView1"
android:layout_below="#+id/textView1"
android:isIndicator="false"
android:numStars="5"
android:stepSize="1" />
<ImageView
android:id="#+id/dropDownButton"
android:layout_width="48dip"
android:layout_height="48dip"
android:layout_alignBottom="#+id/ratingBar1"
android:layout_toRightOf="#+id/ratingBar1"
android:onClick="dropDown"
android:src="#drawable/ddb" />
<RelativeLayout
android:id="#+id/dropDownLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignTop="#+id/textView2"
android:visibility="gone" >
<TextView
android:id="#+id/testTV"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Testing dropdown" />
</RelativeLayout>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/ratingBar1"
android:layout_marginLeft="14dp"
android:layout_marginTop="10dp"
android:text="#string/tipTitle"
android:textColor="#888888"
android:textSize="19sp" />
<FrameLayout
android:id="#+id/quizFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/dropDownButton" />
<TextView
android:id="#+id/tipText"
android:layout_width="175dp"
android:layout_height="wrap_content"
android:layout_below="#+id/textView2"
android:layout_marginLeft="14dp"
android:background="#drawable/round_corners"
android:focusable="false"
android:padding="2dp"
android:text="10%"
android:textColor="#888888"
android:textStyle="bold" />
<ImageButton
android:id="#+id/greyPlus"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_below="#+id/textView2"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:layout_toRightOf="#+id/textView1"
android:background="#drawable/grey_plus" />
<ImageButton
android:id="#+id/greyMinus"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignTop="#+id/greyPlus"
android:layout_toRightOf="#+id/greyPlus"
android:background="#drawable/grey_minus" />
<TextView
android:id="#+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tipText"
android:layout_below="#+id/greyPlus"
android:layout_marginTop="10dp"
android:text="#string/people_dining_title"
android:textColor="#888888"
android:textSize="19sp" />
<TextView
android:id="#+id/textViewPeople"
android:layout_width="175dp"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/TextView02"
android:layout_below="#+id/TextView02"
android:background="#drawable/round_corners"
android:focusable="false"
android:padding="2dp"
android:text="2"
android:textColor="#888888"
android:textStyle="bold" />
<ImageButton
android:id="#+id/greyPlus2"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignLeft="#+id/greyPlus"
android:layout_alignTop="#+id/textViewPeople"
android:background="#drawable/grey_plus" />
<ImageButton
android:id="#+id/greyMinus2"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignLeft="#+id/greyMinus"
android:layout_alignTop="#+id/greyPlus2"
android:background="#drawable/grey_minus" />
<TextView
android:id="#+id/subtotalTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textViewPeople"
android:layout_below="#+id/greyPlus2"
android:layout_marginTop="10dp"
android:text="#string/subtotal"
android:textColor="#888888"
android:textSize="19sp" />
<TextView
android:id="#+id/totalTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/subtotalText"
android:layout_below="#+id/subtotalText"
android:layout_marginTop="10dp"
android:text="#string/total"
android:textColor="#888888"
android:textSize="19sp" />
<TextView
android:id="#+id/totalText"
android:layout_width="175dp"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/totalTitle"
android:layout_alignRight="#+id/subtotalText"
android:layout_below="#+id/totalTitle"
android:background="#drawable/round_corners_blue"
android:focusable="false"
android:padding="2dp"
android:text="TOTAL"
android:textColor="#FFFFFF" />
<EditText
android:id="#+id/subtotalText"
android:layout_width="175dp"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/subtotalTitle"
android:layout_alignRight="#+id/greyMinus2"
android:layout_below="#+id/subtotalTitle"
android:background="#drawable/round_corners"
android:ems="10"
android:hint="SUBTOTAL"
android:inputType="numberDecimal"
android:padding="2dp"
android:textColor="#888888"
android:textStyle="bold" >
</EditText>
<TextView
android:id="#+id/eppTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/totalText"
android:layout_below="#+id/totalText"
android:layout_marginTop="10dp"
android:text="#string/epp"
android:textColor="#888888"
android:textSize="19sp" />
<TextView
android:id="#+id/eppText"
android:layout_width="175dp"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/eppTitle"
android:layout_alignRight="#+id/totalText"
android:layout_below="#+id/eppTitle"
android:background="#drawable/round_corners_blue"
android:focusable="false"
android:padding="2dp"
android:text=""
android:textColor="#FFFFFF" />
<Button
android:id="#+id/buttonDone"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_below="#+id/eppText"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:background="#3fa9f5"
android:fontFamily="helvetica"
android:onClick="done"
android:text="#string/done"
android:textColor="#ffffff"
android:textSize="14sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/settingsButton"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignBottom="#+id/buttonDone"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/buttonDone"
android:layout_toRightOf="#+id/eppText"
android:onClick="openSettings"
android:src="#drawable/smallgear" />
</RelativeLayout>
You can provide alternative layouts by creating the same file in another layout folder, e.g. layout-sw600dp for a screen with smallest width of 600dp. You can preview how it'll look using Android Studio's preview screen.
Check out Android's training for more help
I need same as I attached image file Its Camera Preview Screen : I want to design two transparent layout over framelayout so it looks like this, but when I run it show only camera screen(Framelayout). It not showing two relative layouts.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/camera_preview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#000000"
android:layout_gravity="top"
android:padding="15dp" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="01"
android:textColor="#color/White" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView1"
android:layout_marginTop="5dp"
android:text="Status:"
android:textColor="#color/White" />
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/textView1"
android:layout_marginRight="78dp"
android:src="#drawable/heart" />
<ImageView
android:id="#+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView2"
android:layout_alignLeft="#+id/imageView3"
android:layout_marginTop="10dp"
android:src="#drawable/view" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/imageView3"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/imageView4"
android:text="125 Likes"
android:textColor="#color/White" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView2"
android:layout_toRightOf="#+id/textView2"
android:text="STREAMING" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView3"
android:layout_alignTop="#+id/imageView4"
android:text="24 Viewers"
android:textColor="#color/White" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#77000000"
android:layout_gravity="bottom"
android:padding="10dp" >
<Button
android:id="#+id/button_capture"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#drawable/camera_record"
android:textColor="#color/White" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="50dp"
android:src="#drawable/view_video_big" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="50dp"
android:src="#drawable/swipe_camera" />
</RelativeLayout>
</FrameLayout>
Add ids to the two RelativeLlayouts in layout file..
and get the view object by like this
RelativeLayout layout1=(RelativeLayout) findViewById(R.id.topRelativeLayout);
RelativeLayout layout2=(RelativeLayout) findViewById(R.id.bottomRelativeLayout);
and add this line in your onCreate and test once..
layout1.bringToFront();
layout2.bringToFront();
Try this first of all you have to set your background image to FrameLayout:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/camera_preview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="#drawable/ic_launcher"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#000000"
android:padding="15dp" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="01"
android:textColor="#color/White" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView1"
android:layout_marginTop="5dp"
android:text="Status:"
android:textColor="#color/White" />
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/textView1"
android:layout_marginRight="78dp"
android:src="#drawable/heart" />
<ImageView
android:id="#+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView2"
android:layout_alignLeft="#+id/imageView3"
android:layout_marginTop="10dp"
android:src="#drawable/view" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/imageView3"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/imageView4"
android:text="125 Likes"
android:textColor="#color/White" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView2"
android:layout_toRightOf="#+id/textView2"
android:text="STREAMING" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView3"
android:layout_alignTop="#+id/imageView4"
android:text="24 Viewers"
android:textColor="#color/White" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#77000000"
android:layout_gravity="bottom"
android:visibility="visible"
android:padding="10dp" >
<Button
android:id="#+id/button_capture"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#drawable/camera_record"
android:textColor="#color/White" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="50dp"
android:src="#drawable/view_video_big" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="50dp"
android:src="#drawable/swipe_camera" />
</RelativeLayout>
</FrameLayout>
or follow this link.
I have a scrollable Android layout which is defined by the following code:
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#id/horizontal_rule_in_registration" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="23dp" >
<View
android:id="#+id/advertising_image"
android:layout_width="306dp"
android:layout_height="175dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#drawable/inno_luck_sample_advertisement_picture" />
<TextView
android:id="#+id/advertiser_name_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/advertising_image"
android:layout_marginTop="12dp"
android:textColor="#color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/business_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/advertiser_name_text"
android:layout_marginTop="12dp"
android:textColor="#color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/ad_description_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/business_text"
android:layout_marginTop="12dp"
android:maxLines="2"
android:singleLine="false"
android:textColor="#color/register_text_clr"
android:textSize="18sp" />
<TextView
android:id="#+id/advertiser_contact_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/ad_description_text"
android:layout_marginTop="12dp"
android:textColor="#color/register_text_clr"
android:textSize="18sp" />
<TextView
android:id="#+id/advertiser_address_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/advertiser_contact_text"
android:layout_marginTop="12dp"
android:maxLines="2"
android:singleLine="false"
android:textColor="#color/register_text_clr"
android:textSize="18sp" />
<TextView
android:id="#+id/advertiser_website_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/advertiser_address_text"
android:layout_marginTop="12dp"
android:textColor="#color/register_text_clr"
android:textSize="18sp" />
<Button
android:id="#+id/next_ok_btn"
android:layout_width="190dp"
android:layout_height="29dp"
android:layout_below="#id/advertiser_website_text"
android:layout_centerHorizontal="true"
android:layout_marginTop="12dp"
android:background="#drawable/next_button_bg"
android:gravity="center"
android:text="#string/next"
android:textColor="#color/next_clr"
android:textSize="18sp" />
</RelativeLayout>
</ScrollView>
However as the picture below shows, this does not show the bottom most part of the layout.
How can I overcome this problem?
Try to give padding in your Relative layout
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="23dp"
android:paddingBottom="10dp">
try this code
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_below="#id/horizontal_rule_in_registration" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="23dp" >
<View
android:id="#+id/advertising_image"
android:layout_width="306dp"
android:layout_height="175dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#drawable/inno_luck_sample_advertisement_picture" />
<TextView
android:id="#+id/advertiser_name_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/advertising_image"
android:layout_marginTop="12dp"
android:textColor="#color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/business_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/advertiser_name_text"
android:layout_marginTop="12dp"
android:textColor="#color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/ad_description_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/business_text"
android:layout_marginTop="12dp"
android:maxLines="2"
android:singleLine="false"
android:textColor="#color/register_text_clr"
android:textSize="18sp" />
<TextView
android:id="#+id/advertiser_contact_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/ad_description_text"
android:layout_marginTop="12dp"
android:textColor="#color/register_text_clr"
android:textSize="18sp" />
<TextView
android:id="#+id/advertiser_address_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/advertiser_contact_text"
android:layout_marginTop="12dp"
android:maxLines="2"
android:singleLine="false"
android:textColor="#color/register_text_clr"
android:textSize="18sp" />
<TextView
android:id="#+id/advertiser_website_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/advertiser_address_text"
android:layout_marginTop="12dp"
android:textColor="#color/register_text_clr"
android:textSize="18sp" />
<Button
android:id="#+id/next_ok_btn"
android:layout_width="190dp"
android:layout_height="29dp"
android:layout_below="#id/advertiser_website_text"
android:layout_centerHorizontal="true"
android:layout_marginTop="12dp"
android:background="#drawable/next_button_bg"
android:gravity="center"
android:text="#string/next"
android:textColor="#color/next_clr"
android:textSize="18sp" />
</RelativeLayout>
hope this helps
try this for your ScrollView
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
....
In my app am using customized listed view with text view and Buttons.The screen size is 4.65" 720p(720X1280 : xhdpi),device take this resolution from layout-large folder.when i run it on device.the list view item and header display not fit to the screen like image shown below,some empty space in the end of row.Its not able to fit to the screen.Can any one know please help me to solve this issue.
Header XML Coding
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/search_lay"
android:layout_marginTop="1dp"
android:background="#e8e8e8" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="32dp"
android:text="Item(s)"
android:textColor="#dd1713"
android:textSize="13sp" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="48dp"
android:layout_toRightOf="#+id/textView1"
android:text="Price(Rs.)"
android:textColor="#dd1713"
android:textSize="13sp" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="18dp"
android:layout_toRightOf="#+id/textView3"
android:text="Qty"
android:textColor="#dd1713"
android:textSize="13sp" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="28dp"
android:layout_toRightOf="#+id/textView2"
android:text="Total(Rs.)"
android:textColor="#dd1713"
android:textSize="13sp" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="3dp"
android:text="Fav"
android:textColor="#dd1713"
android:textSize="13sp" />
</RelativeLayout>
Customized List-view XML Coding
<?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" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#ffffff" >
<TextView
android:id="#+id/orderlist_product_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:visibility="gone" />
<RelativeLayout
android:layout_width="30dp"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/fav_img"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="#drawable/fav_order_list_btn" />
<Button
android:id="#+id/special_inst_btn"
android:layout_width="25dp"
android:layout_height="18dp"
android:layout_below="#+id/fav_img"
android:layout_centerHorizontal="true"
android:background="#drawable/special_inst_btn_in_orderlist"
android:gravity="center"
android:text="+"
android:textColor="#ffffff"
android:textSize="14sp" />
</RelativeLayout>
<TextView
android:id="#+id/order_list_itemname"
android:layout_width="95dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="1dp"
android:text="Item name"
android:textColor="#000000"
android:textSize="12sp"
android:typeface="serif" />
<RelativeLayout
android:layout_width="34dp"
android:layout_height="match_parent"
android:layout_marginLeft="2dp" >
<TextView
android:id="#+id/orderlist_offer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="4dp"
android:gravity="center"
android:textColor="#298616"
android:textSize="10sp" />
<TextView
android:id="#+id/orderlist_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:gravity="right"
android:text="200.00"
android:textColor="#000000"
android:textSize="10sp"
android:typeface="serif" />
</RelativeLayout>
<Button
android:id="#+id/orderlist_minus"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginTop="1dp"
android:background="#drawable/sub_button_click" />
<EditText
android:id="#+id/order_list_quantity"
android:layout_width="27dp"
android:layout_height="25dp"
android:layout_marginTop="13dp"
android:background="#drawable/et_bg"
android:ems="10"
android:focusable="false"
android:focusableInTouchMode="false"
android:gravity="center"
android:inputType="number"
android:textColor="#000000"
android:textSize="12dp"
android:typeface="serif" >
<requestFocus />
</EditText>
<Button
android:id="#+id/orderlist_plus"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="center"
android:layout_marginTop="1dp"
android:background="#drawable/plus_btn_click" />
<TextView
android:id="#+id/orderlist_total"
android:layout_width="43dp"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:layout_marginTop="13dp"
android:gravity="right"
android:text="1000.00"
android:textColor="#000000"
android:textSize="11sp"
android:typeface="serif" />
<Button
android:id="#+id/orderlist_delete"
android:layout_width="23dp"
android:layout_height="23dp"
android:layout_gravity="center"
android:layout_marginLeft="3dp"
android:layout_marginTop="1dp"
android:background="#drawable/order_list_delete" />
</LinearLayout>
</RelativeLayout>
i m giving u a demo.this layout will work on all size layout,this will definitely help u #Yugesh.
weight works percentage-wise on all screen.
<?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" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".30"
android:gravity="center_horizontal" >
<ImageView
android:id="#+id/image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/image1"
android:src="#drawable/ic_launcher" />
</RelativeLayout>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".30"
android:text="30%" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".20"
android:text="20%" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".20"
android:text="20%" />
</LinearLayout>
</RelativeLayout>
further more,if there is any query,then please ask...