Android : Relativelayout in Framelayout not showing up (Custom Camera Preview Screen) - android

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.

Related

Changing size of ImageView inside ScrollView crash the applications

I am just a beginner at android studio.So bear with me guys
I am creating a android app with ScrollView. my code worked well in the beginning,I could scroll through the screen.(I have 3 ImageView widgets inside the scroll view of each size 70dp x 70dp) but when i changed the size of the each image to 300dp X 200dp the app crashes :(
Here is my working code :
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
android:fillViewport="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="231dp"
android:layout_height="58dp"
android:textSize="60dp"
android:text="TEXT"
android:textColor="#e0b122"
android:layout_marginTop="10dp"
android:layout_marginLeft="115dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Small text"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:id="#+id/textView5"
android:textSize="30dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="text....................................text"
android:textColor="#e0b122"
android:id="#+id/textView6" />
<ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:src="#drawable/image1"
android:layout_marginLeft="5dp"
android:id="#+id/imageView3"
android:layout_gravity="center_horizontal" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="text"
android:layout_marginLeft="10dp"
android:id="#+id/textView7"
android:textSize="30dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="text....................................text"
android:textColor="#e0b122"
android:id="#+id/textView8" />
<ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginRight="20dp"
android:src="#drawable/image2"
android:layout_marginLeft="10dp"
android:id="#+id/imageView5"
android:layout_gravity="center_horizontal" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:id="#+id/textView9"
android:textSize="30dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="text....................................text"
android:textColor="#e0b122"
android:id="#+id/textView10"
android:layout_gravity="center_horizontal" />
<ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:src="#drawable/image3"
android:layout_marginLeft="10dp"
android:id="#+id/imageView6"
android:layout_gravity="center_horizontal"
android:layout_marginRight="20dp" />
</LinearLayout>
</ScrollView>
But When i change the size of ImageView to 70dp X 70dp the appication crash
Eg.
<ImageView
android:layout_width="350dp"
android:layout_height="250dp"
android:src="#drawable/image3"
android:layout_marginLeft="10dp"
android:id="#+id/imageView6"
android:layout_gravity="center_horizontal"
android:layout_marginRight="20dp"/>
try this :-
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:padding="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/main_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:text="TEXT"
android:textColor="#e0b122"
android:textSize="60dp" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/main_content"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:text="Small text"
android:textSize="30dp" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView5"
android:layout_centerInParent="true"
android:text="text....................................text"
android:textColor="#e0b122" />
<ImageView
android:id="#+id/imageView3"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_below="#+id/textView6"
android:layout_centerInParent="true"
android:layout_marginLeft="5dp"
android:src="#drawable/image1" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView3"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:text="text"
android:textSize="30dp" />
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView7"
android:layout_centerInParent="true"
android:text="text....................................text"
android:textColor="#e0b122" />
<ImageView
android:id="#+id/imageView5"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_below="#+id/textView8"
android:layout_centerInParent="true"
android:layout_marginLeft="5dp"
android:src="#drawable/image2" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView5"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:text="text"
android:textSize="30dp" />
<TextView
android:id="#+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView9"
android:layout_centerInParent="true"
android:text="text....................................text"
android:textColor="#e0b122" />
<ImageView
android:id="#+id/imageView6"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_below="#+id/textView10"
android:layout_centerInParent="true"
android:layout_marginLeft="5dp"
android:src="#drawable/image3" />
</RelativeLayout>
</ScrollView>
Replace It
<ImageView
android:layout_width="350dp"
android:layout_height="250dp"
android:src="#drawable/image3"
android:layout_marginLeft="10dp"
android:id="#+id/imageView6"
android:layout_gravity="center_horizontal"
android:layout_marginRight="20dp"/>
With
<ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:src="#drawable/image3"
android:layout_marginLeft="10dp"
android:id="#+id/imageView6"
android:layout_centerInParent="true"
android:layout_marginRight="20dp"
android:scaleType="fitXY"/>
hope It will help you...

Android ImageView in Eclipse - Problems with image location

I'm trying to insert some pixel art for my app as an ImageView, but it's very stubborn once I have it in. Specifically, it's centered and pretty much locked into a grid.
I would like to naturally place the sprite where I want to instead of having it snap to a grid. Any suggestions? Here it is:
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/cloud1" />
EDIT: Full XML
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:gravity="center"
android:text="Enter Two Numbers"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold" />
<EditText
android:id="#+id/editOp1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:ems="10"
android:inputType="numberDecimal" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/editOp2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="numberDecimal" />
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="15dp"
android:gravity="center" >
<ImageButton
android:id="#+id/btnAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#null"
android:src="#drawable/sun" />
<Button
android:id="#+id/btnSubtract"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textStyle="bold" />
<Button
android:id="#+id/btnDivide"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/"
android:textStyle="bold" />
<Button
android:id="#+id/btnMultiply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="*"
android:textStyle="bold" />
<Button
android:id="#+id/clear"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CLR" />
</TableRow>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:gravity="center"
android:text="RESULT"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="0.00"
android:textAppearance="?android:attr/textAppearanceLarge" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:src="#drawable/grass" />
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/imageView2"
android:src="#drawable/grass" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/imageView3"
android:src="#drawable/grass" />
<ImageView
android:id="#+id/imageView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/imageView4"
android:layout_marginLeft="12dp"
android:layout_marginTop="14dp"
android:src="#drawable/cloud2" />
<ImageView
android:id="#+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="43dp"
android:src="#drawable/cloud1" />
</RelativeLayout>
All you wanted to do is make the xml layout root as RelativeLayout & Go to Design tab, drag to where ever you want it to be.
Hope it helps!

text view is not showing up in relative layout

I have a screen with relative layouts which contains images and text views.I am trying to add one text view but it is not showing up..I can't find out the reason.This is my whole xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#drawable/orangestrip"
android:gravity="left|center"
android:text="Choose your flag, Pay in your Home currency"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ffffff" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/textView1"
android:background="#drawable/orangestrip"
android:gravity="left|center"
android:text="اختيار العلم الخاص بك، ودفع بالعملة المحلية الخاصة بك"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ffffff" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:background="#drawable/stripblue"
android:gravity="center"
android:text="Cancel"
android:textColor="#ffffff" />
<RelativeLayout
android:id="#+id/relativeLayout2"
android:layout_width="450dp"
android:layout_height="500dp"
android:layout_above="#+id/button1"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/textView4"
android:background="#drawable/imageborder" >
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="450dp"
android:layout_height="500dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="#drawable/imageborder" >
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="400dp"
android:layout_height="320dp"
android:layout_above="#+id/textView2"
android:layout_centerHorizontal="true"
android:layout_marginBottom="17dp" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/imageButton1"
android:layout_alignParentBottom="true"
android:layout_marginLeft="85dp"
android:text="curr"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="35sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView2"
android:layout_alignLeft="#+id/textView2"
android:gravity="center"
android:text="rate"
android:textColor="#android:color/black" />
</RelativeLayout>
<RelativeLayout
android:layout_width="450dp"
android:layout_height="500dp"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/relativeLayout1"
android:background="#drawable/imageborder" >
<ImageButton
android:id="#+id/imageButton2"
android:layout_width="400dp"
android:layout_height="320dp"
android:layout_above="#+id/textView3"
android:layout_centerHorizontal="true"
android:layout_marginBottom="16dp"
android:background="#drawable/uae" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignRight="#+id/imageButton2"
android:layout_marginRight="123dp"
android:text="curr"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="35sp"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_above="#+id/relativeLayout2"
android:layout_alignParentRight="true"
android:background="#null"
android:src="#drawable/mashreqlogosmall" />
</RelativeLayout>
</LinearLayout>
This is the relative layout where I am trying to add the text view but its not showing up...textview with id textview5 is not showing up.
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="450dp"
android:layout_height="500dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="#drawable/imageborder" >
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="400dp"
android:layout_height="320dp"
android:layout_above="#+id/textView2"
android:layout_centerHorizontal="true"
android:layout_marginBottom="17dp" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/imageButton1"
android:layout_alignParentBottom="true"
android:layout_marginLeft="85dp"
android:text="curr"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="35sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView2"
android:layout_alignLeft="#+id/textView2"
android:gravity="center"
android:text="rate"
android:textColor="#android:color/black" />
</RelativeLayout>
please help..
try like this
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relativeLayout1"
android:layout_width="450dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="#drawable/ic_launcher" >
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="400dp"
android:layout_height="320dp"
android:layout_above="#+id/textView5"
android:layout_centerHorizontal="true"
android:layout_marginBottom="17dp" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/imageButton1"
android:layout_alignParentBottom="true"
android:layout_marginLeft="85dp"
android:text="curr"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="35sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView2"
android:layout_alignLeft="#+id/textView2"
android:gravity="center"
android:text="rate"
android:textColor="#android:color/black" />
</RelativeLayout>

customized list view with text view and button not support for multiple screen?

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...

Can't resize a RelativeLayout inside a ScrollView to fill the whole screen

I am having a weird issue that I am not sure how to fix. I have a RelativeLayout inside a ScrollView and this scrollView has it's height set to fill_parent. So does the RelativeLayout. Still, the contents are not filling the entire screen and it's going only to the wrap_content of the last layout inside this RelativeLayout.
Here is my code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.pontai"
android:id="#+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="#+id/relativeLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/relativeLayout3"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/relativeLayout5"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="How much points you have here:"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/textViewTotalPoints1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="120"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<RelativeLayout
android:id="#+id/relativeLayout4"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:layout_alignLeft="#+id/relativeLayout3"
android:layout_below="#+id/linearLayout1"
android:layout_marginTop="5dp"
android:layout_toLeftOf="#+id/textView7"
android:orientation="vertical" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:text="Ratings"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textViewPositivePoints"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_below="#+id/textView3"
android:layout_toLeftOf="#+id/textView3"
android:src="#drawable/thumbs_up_focused" />
<TextView
android:id="#+id/textViewNegativePoints"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/textView3"
android:layout_centerVertical="true"
android:layout_marginRight="3dp"
android:text="22"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textViewNegativePoints"
android:layout_alignBottom="#+id/textViewNegativePoints"
android:layout_alignLeft="#+id/textView3"
android:layout_marginLeft="3dp"
android:text="33"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:id="#+id/imageView3"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignTop="#+id/imageView2"
android:layout_toRightOf="#+id/textViewNegativePoints"
android:src="#drawable/thumbs_down_focused" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayout5"
android:layout_width="95dp"
android:layout_height="80dp"
android:layout_alignRight="#+id/relativeLayout3"
android:layout_alignTop="#+id/relativeLayout4"
android:layout_toRightOf="#+id/textView7"
android:orientation="vertical" >
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:text="Comments"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="#drawable/speech_bubble" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeLayout4"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp" >
<TextView
android:id="#+id/textViewOfferName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="Offer Name"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textViewBusinessName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="35dp"
android:text="Business Name"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textViewBusinessAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="60dp"
android:text="Business Address"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textViewNull1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="80dp"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textViewTotalPoints"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textViewNull1"
android:layout_centerHorizontal="true"
android:text="0/0"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="#+id/buttonUseNow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textViewTotalPoints"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="#string/offer_details_use_now" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/buttonUseNow"
android:layout_marginTop="10dp"
android:text="#string/_terms_and_conditions_"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/textViewTermsConditions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView2"
android:layout_marginTop="2dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/relativeLayout5"
android:layout_centerHorizontal="true"
android:layout_marginBottom="30dp"
android:text="e"
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="invisible" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Anyone have ideas of how I can make the RelativeLayout2 to have the same height as the ScrollView, meaning, I want it to reach the bottom of the screen?
Thanks and regards,
Felipe
I have faced this problem before. Just Use android:fillViewport="true" in your scrollview and it will fill up the screen.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >

Categories

Resources