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...
Related
I developed an android application in which the scroll-view is not scrolling.. I am posting the code here please check and if found any error please help.. Here I used ScrollView as root and then LinearLayout... but this is not scrolling up.. I Updated the xml still not working
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<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="wrap_content"
android:gravity="center|top"
android:orientation="vertical"
android:background="#color/colorPrimary"
android:weightSum="1">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:id="#+id/arrowImageView"
android:src="#drawable/logo_grey"
/>
<TextView
android:id="#+id/NameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="20dp"
android:textStyle="bold"
android:textColor="#android:color/white"
android:gravity="center_horizontal" />
<TextView
android:id="#+id/dTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="15dp"
android:textColor="#android:color/white"
android:gravity="center_horizontal" />
<TextView
android:id="#+id/positionTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="15dp"
android:textColor="#android:color/white"
android:gravity="center_horizontal" />
<TextView
android:id="#+id/IdTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_id"
android:textSize="15dp"
android:layout_marginBottom="#dimen/activity_vertical_margin"
android:textColor="#android:color/white"
android:gravity="center_horizontal" />
<!--items-->
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#android:color/white"
android:paddingTop="10dp"
android:paddingBottom="10dp">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/image1"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:src="#drawable/takeoff_color"
android:layout_alignParentStart="true"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_b"
android:textSize="15dp"
android:layout_toEndOf="#id/image1"
android:textStyle="bold"
android:textColor="#color/colorPrimary" />
<TextView
android:id="#+id/sTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="15dp"
android:textStyle="bold"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:textColor="#color/colorPrimary" />
</RelativeLayout>
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/image2"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_alignParentStart="true"
android:src="#drawable/document"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_date"
android:textSize="15dp"
android:textStyle="bold"
android:layout_toEndOf="#id/image2"
android:textColor="#android:color/white" />
<TextView
android:id="#+id/DateTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="15dp"
android:textStyle="bold"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:textColor="#android:color/white" />
</RelativeLayout>
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#android:color/white"
android:paddingTop="10dp"
android:paddingBottom="10dp"
>
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/image3"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_alignParentStart="true"
android:src="#drawable/document_color"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_end_of"
android:textSize="15dp"
android:textStyle="bold"
android:layout_toEndOf="#id/image3"
android:textColor="#color/colorPrimary" />
<TextView
android:id="#+id/endOfTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="15dp"
android:gravity="start"
android:textStyle="bold"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:textColor="#color/colorPrimary" />
</RelativeLayout>
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/imageView"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_alignParentStart="true"
android:src="#drawable/ic_action_money"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_c"
android:textSize="15dp"
android:textStyle="bold"
android:layout_toEndOf="#+id/imageView"
android:textColor="#android:color/white" />
<TextView
android:id="#+id/currentSalaryTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="15dp"
android:textStyle="bold"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:textColor="#android:color/white" />
</RelativeLayout>
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#android:color/white"
android:paddingTop="10dp"
android:paddingBottom="10dp"
>
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/imageView2"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_alignParentStart="true"
android:src="#drawable/bag_color"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_h_total"
android:textSize="15dp"
android:textStyle="bold"
android:layout_toEndOf="#+id/imageView2"
android:textColor="#color/colorPrimary" />
<TextView
android:id="#+id/salaryTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="15dp"
android:textStyle="bold"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:textColor="#color/colorPrimary" />
</RelativeLayout>
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp"
>
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/imageView3"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_alignParentStart="true"
android:src="#drawable/purchase_order"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_g"
android:textSize="15dp"
android:textStyle="bold"
android:layout_toEndOf="#+id/imageView3"
android:textColor="#android:color/white" />
<TextView
android:id="#+id/gTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="15dp"
android:textStyle="bold"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:textColor="#android:color/white" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
EDITED AS BELOW, but still not working well, the scrollbar stop at half of label name:"label_h_total"
<ScrollView 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:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center|top"
android:orientation="vertical"
android:background="#color/colorPrimary"
>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:id="#+id/arrowImageView"
android:src="#drawable/logo_grey"
/>
<TextView
android:id="#+id/NameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="20dp"
android:textStyle="bold"
android:textColor="#android:color/white"
android:gravity="center_horizontal" />
<TextView
android:id="#+id/dTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="15dp"
android:textColor="#android:color/white"
android:gravity="center_horizontal" />
<TextView
android:id="#+id/positionTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="15dp"
android:textColor="#android:color/white"
android:gravity="center_horizontal" />
<TextView
android:id="#+id/IdTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_id"
android:textSize="15dp"
android:layout_marginBottom="#dimen/activity_vertical_margin"
android:textColor="#android:color/white"
android:gravity="center_horizontal" />
<!--items-->
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#android:color/white"
android:paddingTop="10dp"
android:paddingBottom="10dp">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/image1"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:src="#drawable/takeoff_color"
android:layout_alignParentStart="true"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_b"
android:textSize="15dp"
android:layout_toEndOf="#id/image1"
android:textStyle="bold"
android:textColor="#color/colorPrimary" />
<TextView
android:id="#+id/sTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="15dp"
android:textStyle="bold"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:textColor="#color/colorPrimary" />
</RelativeLayout>
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/image2"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_alignParentStart="true"
android:src="#drawable/document"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_date"
android:textSize="15dp"
android:textStyle="bold"
android:layout_toEndOf="#id/image2"
android:textColor="#android:color/white" />
<TextView
android:id="#+id/DateTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="15dp"
android:textStyle="bold"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:textColor="#android:color/white" />
</RelativeLayout>
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#android:color/white"
android:paddingTop="10dp"
android:paddingBottom="10dp"
>
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/image3"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_alignParentStart="true"
android:src="#drawable/document_color"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_end_of"
android:textSize="15dp"
android:textStyle="bold"
android:layout_toEndOf="#id/image3"
android:textColor="#color/colorPrimary" />
<TextView
android:id="#+id/endOfTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="15dp"
android:gravity="start"
android:textStyle="bold"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:textColor="#color/colorPrimary" />
</RelativeLayout>
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/imageView"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_alignParentStart="true"
android:src="#drawable/ic_action_money"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_c"
android:textSize="15dp"
android:textStyle="bold"
android:layout_toEndOf="#+id/imageView"
android:textColor="#android:color/white" />
<TextView
android:id="#+id/currentSalaryTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="15dp"
android:textStyle="bold"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:textColor="#android:color/white" />
</RelativeLayout>
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#android:color/white"
android:paddingTop="10dp"
android:paddingBottom="10dp"
>
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/imageView2"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_alignParentStart="true"
android:src="#drawable/bag_color"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_h_total"
android:textSize="15dp"
android:textStyle="bold"
android:layout_toEndOf="#+id/imageView2"
android:textColor="#color/colorPrimary" />
<TextView
android:id="#+id/salaryTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="15dp"
android:textStyle="bold"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:textColor="#color/colorPrimary" />
</RelativeLayout>
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp"
>
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/imageView3"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_alignParentStart="true"
android:src="#drawable/purchase_order"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_g"
android:textSize="15dp"
android:textStyle="bold"
android:layout_toEndOf="#+id/imageView3"
android:textColor="#android:color/white" />
<TextView
android:id="#+id/gTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="15dp"
android:textStyle="bold"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:textColor="#android:color/white" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
The Warning
A scrolling widget such as a ScrollView should not contain any nested scrolling widgets since this has various usability issues
This should be works. There was a problem with the LinearLayout, the height was wrap_content. The first child of scrollview needs to have only match_parent for both width and height and that's it.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#color/colorPrimary">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:id="#+id/arrowImageView"
android:src="#drawable/logo_grey"
/>
<TextView
android:id="#+id/NameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="20dp"
android:textStyle="bold"
android:textColor="#android:color/white"
android:gravity="center_horizontal" />
<TextView
android:id="#+id/dTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="15dp"
android:textColor="#android:color/white"
android:gravity="center_horizontal" />
<TextView
android:id="#+id/positionTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="15dp"
android:textColor="#android:color/white"
android:gravity="center_horizontal" />
<TextView
android:id="#+id/IdTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_id"
android:textSize="15dp"
android:layout_marginBottom="#dimen/activity_vertical_margin"
android:textColor="#android:color/white"
android:gravity="center_horizontal" />
<!--items-->
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#android:color/white"
android:paddingTop="10dp"
android:paddingBottom="10dp">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/image1"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:src="#drawable/takeoff_color"
android:layout_alignParentStart="true"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_b"
android:textSize="15dp"
android:layout_toEndOf="#id/image1"
android:textStyle="bold"
android:textColor="#color/colorPrimary" />
<TextView
android:id="#+id/sTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="15dp"
android:textStyle="bold"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:textColor="#color/colorPrimary" />
</RelativeLayout>
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/image2"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_alignParentStart="true"
android:src="#drawable/document"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_date"
android:textSize="15dp"
android:textStyle="bold"
android:layout_toEndOf="#id/image2"
android:textColor="#android:color/white" />
<TextView
android:id="#+id/DateTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="15dp"
android:textStyle="bold"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:textColor="#android:color/white" />
</RelativeLayout>
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#android:color/white"
android:paddingTop="10dp"
android:paddingBottom="10dp"
>
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/image3"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_alignParentStart="true"
android:src="#drawable/document_color"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_end_of"
android:textSize="15dp"
android:textStyle="bold"
android:layout_toEndOf="#id/image3"
android:textColor="#color/colorPrimary" />
<TextView
android:id="#+id/endOfTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="15dp"
android:gravity="start"
android:textStyle="bold"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:textColor="#color/colorPrimary" />
</RelativeLayout>
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/imageView"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_alignParentStart="true"
android:src="#drawable/ic_action_money"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_c"
android:textSize="15dp"
android:textStyle="bold"
android:layout_toEndOf="#+id/imageView"
android:textColor="#android:color/white" />
<TextView
android:id="#+id/currentSalaryTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="15dp"
android:textStyle="bold"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:textColor="#android:color/white" />
</RelativeLayout>
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#android:color/white"
android:paddingTop="10dp"
android:paddingBottom="10dp"
>
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/imageView2"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_alignParentStart="true"
android:src="#drawable/bag_color"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_h_total"
android:textSize="15dp"
android:textStyle="bold"
android:layout_toEndOf="#+id/imageView2"
android:textColor="#color/colorPrimary" />
<TextView
android:id="#+id/salaryTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="15dp"
android:textStyle="bold"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:textColor="#color/colorPrimary" />
</RelativeLayout>
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp"
>
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/imageView3"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_alignParentStart="true"
android:src="#drawable/purchase_order"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_g"
android:textSize="15dp"
android:textStyle="bold"
android:layout_toEndOf="#+id/imageView3"
android:textColor="#android:color/white" />
<TextView
android:id="#+id/gTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="15dp"
android:textStyle="bold"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:textColor="#android:color/white" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|top"
android:orientation="vertical"
android:background="#color/colorPrimary"
android:weightSum="1">
xmlns:tools="http://schemas.android.com/tools" put this in scrollview and edit child of scrollview.
I am displaying text and images in a list format next to each other but I can't get them to line up perfectly center next to each other in a straight line what am I missing
Here is my layout code below
<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:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textSize="14dp"
android:textStyle="bold"
android:layout_gravity="center|right"
android:gravity="center|right"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
/>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/textView1"
android:layout_gravity="center|right"
android:gravity="center|right"
android:src="#drawable/image_ls"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
/>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|right"
android:text="TextView"
android:textSize="14dp"
android:layout_toRightOf="#+id/imageView1"
android:textStyle="bold"
android:gravity="center|right"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
/>
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_gravity="center|right"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/textView2"
android:src="#drawable/image_ls"
android:gravity="center|right"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
/>
</RelativeLayout>
This does work:
<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"
android:padding="5dp"
android:gravity="center_vertical|center_horizontal"
android:background="#color/gray_dark">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="TextView"
android:textSize="14dp"
android:textStyle="bold"
android:layout_gravity="center_vertical|right"
android:gravity="center_vertical|right"
android:layout_marginLeft="5dp"
/>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toRightOf="#+id/textView1"
android:layout_gravity="center_vertical|right"
android:gravity="center_vertical|right"
android:src="#drawable/image_ls"
android:layout_marginLeft="5dp"
/>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical|right"
android:text="TextView"
android:textSize="14dp"
android:layout_toRightOf="#+id/imageView1"
android:textStyle="bold"
android:gravity="center_vertical|right"
android:layout_marginLeft="5dp"
/>
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toRightOf="#+id/textView2"
android:src="#drawable/image_ls"
android:layout_gravity="center_vertical|right"
android:gravity="center_vertical|right"
android:layout_marginLeft="5dp"
/>
</RelativeLayout>
i would prefer a linear layout over relative for this situation with this simple layout design, it is easier and straight forward you just need to use:
android:layout_gravity="center_vertical"
and play around with weights if any other size restriction is required.
here is the solution hope its what you need:
<?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"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello"
android:textStyle="bold"
android:layout_gravity="center_vertical"
android:layout_marginTop="10dp"
/>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher"
android:layout_gravity="center_vertical"
android:layout_marginTop="10dp"
/>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello"
android:textStyle="bold"
android:layout_gravity="center_vertical"
android:layout_marginTop="10dp"
/>
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="#drawable/ic_launcher"
android:layout_marginTop="10dp"
/>
</LinearLayout>
</LinearLayout>
I am writing this layout code for my listview.
Below is d code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="5dp" >
<ImageView
android:id="#+id/thumb"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="10dp"
android:paddingBottom="10dp"
android:contentDescription="#string/app_name" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:layout_toLeftOf="#+id/arrow"
android:layout_toRightOf="#+id/thumb"
android:orientation="vertical" >
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/title"
android:textSize="18sp"
android:textStyle="bold"
android:textColor="#color/white" />
<TextView
android:id="#+id/desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="#string/desc"
android:textSize="12sp" />
</LinearLayout>
<ImageView
android:id="#+id/arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:contentDescription="#string/app_name"
android:src="#drawable/ic_action_arrow_next" />
</RelativeLayout>
In the parent element of RelativeLayout the first child element ImageView is where the problem resides, in which all the layout margin properties except layout_marginBottom is working.
What could be the problem, if someone can figure it out
Desired Image
What I have right now
Try this layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="12dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="12dp" >
<ImageView
android:id="#+id/thumb"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:contentDescription="#string/app_name" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="22dp"
android:layout_marginRight="16dp"
android:layout_toLeftOf="#+id/arrow"
android:layout_toRightOf="#+id/thumb"
android:orientation="vertical" >
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/app_name"
android:textColor="#color/white"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="#string/app_name"
android:textSize="12sp" />
</LinearLayout>
<ImageView
android:id="#+id/arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:contentDescription="#string/app_name"
android:src="#drawable/ic_launcher" />
</RelativeLayout>
try this..change ur imageview like this
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp" >
<ImageView
android:id="#+id/thumb"
android:layout_width="70dp"
android:layout_height="70dp"
android:contentDescription="#string/app_name"
android:paddingBottom="10dp"
android:paddingLeft="15dp"
android:paddingRight="10dp"
android:paddingTop="20dp"
android:src="#drawable/ic_launcher" />
<ImageView
android:id="#+id/arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:contentDescription="#string/app_name"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/desc"
android:layout_toRightOf="#+id/thumb"
android:text="titleDsdsadasds"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/arrow"
android:layout_alignLeft="#+id/title"
android:text="descsdfsdfdfsdf"
android:textSize="12sp" />
</RelativeLayout>
well i can see that you have not given any margin bottom to your imageview.Correct me if i'm wrong but i guess you want android:layout_marginBottom="10dp" instead of android:paddingBottom="10dp".So you may want to replace it like below-
<ImageView
android:id="#+id/thumb"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:contentDescription="#string/app_name" />
padding is to give spacing from inside of the view and margin for outside.
Try This
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="15dp"
android:paddingBottom="15dp" >
<ImageView
android:id="#+id/thumb"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:layout_marginRight="10dp"
android:contentDescription="#string/app_name"
android:paddingBottom="10dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:layout_toLeftOf="#+id/arrow"
android:layout_toRightOf="#+id/thumb"
android:orientation="vertical" >
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ddd"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="AAAAAA"
android:textSize="12sp" />
</LinearLayout>
<ImageView
android:id="#+id/arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:contentDescription="AAAAAAAAAAA"
android:src="#drawable/ic_launcher" />
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.
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...