Center TextView between Button and TextView? - java

I have this layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="20dp"
android:textSize="16sp"
android:textStyle="bold"
android:gravity="center_horizontal"
android:textColor="#color/red"
android:text="#string/inf" />
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="60dp"
android:textSize="28sp"
android:gravity="center_horizontal"
android:textStyle="bold"
android:text="#string/ben" />
<TextView
android:id="#+id/textView3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="120dp"
android:gravity="center_horizontal"
android:textSize="18sp"
/>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_centerInParent="true"
android:text="#string/verifica" />
<TextView
android:id="#+id/textView4"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="330dp"
android:gravity="center_horizontal"
android:textSize="18sp"
/>
</RelativeLayout>
Running the application on my Nexus TextView3 looks good, centered between the TextView2 and Button, but on other phones do not.
Do you have ideas on how I can center it between the second TextView and the Button? And to insert a ScrollView?

See following code. It may helps you.
<?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:weightSum = "5" >
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="20dp"
android:textSize="16sp"
android:layout_weight = "1"
android:textStyle="bold"
android:gravity="center_horizontal"
android:textColor="#color/red"
android:text="#string/inf" />
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="60dp"
android:layout_weight = "1
android:textSize="28sp"
android:gravity="center_horizontal"
android:textStyle="bold"
android:text="#string/ben" />
<TextView
android:id="#+id/textView3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight = "1
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="120dp"
android:gravity="center_horizontal"
android:textSize="18sp"
/>
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight = "1
android:layout_gravity="center_vertical|center_horizontal"
android:layout_centerInParent="true"
android:text="#string/verifica" />
<TextView
android:id="#+id/textView4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_weight = "1
android:layout_marginTop="330dp"
android:gravity="center_horizontal"
android:textSize="18sp"
/>
</RelativeLayout>

Scrollview only supports a single child take this into consideration, Here is your layout
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="20dp"
android:gravity="center_horizontal"
android:text="#string/inf"
android:textColor="#color/red"
android:textSize="16sp"
android:textStyle="bold" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_marginTop="60dp" >
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:gravity="center_horizontal"
android:text="TextView 2"
android:textSize="28sp"
android:textStyle="bold" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center_vertical|center_horizontal"
android:text="#string/verifica" />
<TextView
android:id="#+id/textView3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginTop="120dp"
android:gravity="center_horizontal"
android:text="TextView 3"
android:textSize="18sp" />
</RelativeLayout>
<TextView
android:id="#+id/textView4"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="330dp"
android:gravity="center_horizontal"
android:textSize="18sp" />
</RelativeLayout>
</ScrollView>]![enter image description here][2]

Related

How to stretch Imagview in xml layout and show other button to left of it

I'm using Relativelayout within cardview layout to show the user details. But I want to show the two button at the end with equal width on and everything in the left side of Image which will stretch from Top to bottom.
But I'm not able to do so.
here is my xml code
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:layout_marginBottom="2dp"
app:cardCornerRadius="8dp"
app:cardElevation="8dp"
>
<ImageView
android:id="#+id/contact_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:background="#fff"
android:src="#drawable/binil"
android:padding="1dp" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/top"
android:padding="5dp">
<TextView
android:id="#+id/contact_name"
android:layout_width="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Sagar Rawal"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:textStyle="bold" />
<TextView
android:id="#+id/contact_mobile"
android:text="9868336847"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/contact_name"
android:layout_alignParentLeft="true"
android:textStyle="bold" />
<TextView
android:id="#+id/contact_address"
android:layout_below="#+id/contact_name"
android:layout_width="wrap_content"
android:text="Jumla"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:textStyle="bold"
android:layout_toRightOf="#+id/contact_mobile" />
<TextView
android:id="#+id/contact_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="searchbbc1881#gmail.com"
android:layout_below="#+id/contact_mobile"
android:layout_alignParentLeft="true"
android:textStyle="bold" />
<ImageButton
android:layout_below="#+id/contact_email"
android:id="#+id/call"
android:background="#drawable/shape_button"
android:layout_width="wrap_content"
android:src="#drawable/ic_call_black_24dp"
android:layout_height="wrap_content" />
<ImageButton
android:layout_toRightOf="#id/call"
android:layout_below="#+id/contact_email"
android:background="#drawable/shape_button"
android:layout_width="wrap_content"
android:src="#drawable/ic_email_black_24dp"
android:layout_height="wrap_content" />
</RelativeLayout>
</android.support.v7.widget.CardView>
My output is
But I want something similar to this
Where two buttons will equally stretch to left side of Image.
Please help
Try using LinearLayout weightSum like this
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="100">
<TextView
android:layout_width="0dp"
android:layout_weight="50"
android:layout_height="wrap_content"
android:text="text1!" />
<TextView
android:layout_width="0dp"
android:layout_weight="50"
android:layout_height="wrap_content"
android:text="text2!" />
</LinearLayout>
Update:
Replace your code with this, it will solve your issue
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:padding="5dp"
app:cardCornerRadius="8dp"
app:cardElevation="8dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="1">
<RelativeLayout
android:id="#+id/top"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".7"
android:padding="5dp">
<TextView
android:id="#+id/contact_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Sagar Rawal"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold" />
<TextView
android:id="#+id/contact_mobile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/contact_name"
android:text="9868336847"
android:textStyle="bold" />
<TextView
android:id="#+id/contact_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/contact_name"
android:layout_marginLeft="15dp"
android:layout_toRightOf="#+id/contact_mobile"
android:text="Jumla"
android:textStyle="bold" />
<TextView
android:id="#+id/contact_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/contact_mobile"
android:text="searchbbc1881#gmail.com"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/contact_email"
android:weightSum="1">
<ImageButton
android:id="#+id/call"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="#+id/contact_email"
android:layout_weight=".5"
android:background="#drawable/shape_button"
android:src="#drawable/ic_email_black_24dp"
/>
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="#+id/contact_email"
android:layout_toRightOf="#id/call"
android:layout_weight=".5"
android:background="#drawable/shape_button"
android:src="#drawable/ic_email_black_24dp"
/>
</LinearLayout>
</RelativeLayout>
<ImageView
android:id="#+id/contact_profile"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".3"
android:background="#fff"
android:padding="1dp"
android:src="#drawable/ic_launcher_background" />
</LinearLayout>
</android.support.v7.widget.CardView>
Try to reorganize it this way:

how put image view to right to row of listview

how can i put image view to right of row of a list view?(square with image to right of row)
I hope that you can help me!
Thanks in advance everybody!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
this is my XML:
<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:orientation="horizontal" >
<CheckBox
android:id="#+id/chk_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true" />
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:orientation="vertical"
android:layout_weight="1" >
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/chk_box"
android:textStyle="bold"
android:textColor="#000000" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/caratteristica"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/name"
android:layout_toRightOf="#id/chk_box"
android:textStyle="italic" />
</LinearLayout>
<!-- <TextView
android:id="#+id/id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textSize="12sp"
android:textStyle="italic"/>-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/dist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/caratteristica"
android:layout_toRightOf="#id/chk_box"
android:textSize="12sp"
android:textStyle="italic" />
<TextView
android:id="#+id/valuta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textSize="12sp"
android:textStyle="italic" />
</LinearLayout>
<EditText
android:layout_width="196dp"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="#+id/editText"
android:hint="quantità"
>
</EditText>
</LinearLayout>
</LinearLayout>
AND THIS IS PIC:
try this may be it helps you
<?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="horizontal"
>
<ImageView
android:background="#drawable/iconsmile"
android:layout_width="wrap_content"
android:layout_marginRight="10dp"
android:layout_height="wrap_content"
android:id="#+id/checkBox" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:text="I am here for you"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView1" />
<TextView
android:text="I am here for you"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView2" />
<TextView
android:text="I am here for you"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView3" />
</LinearLayout>
</LinearLayout>
Update Your Row to add image in right in center in
I used the image of launcher you use what u take...
<?xml version="1.0" encoding="utf-8"?>
<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:orientation="horizontal" >
<CheckBox
android:id="#+id/chk_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true" />
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:orientation="vertical"
android:layout_weight="1" >
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/chk_box"
android:textStyle="bold"
android:textColor="#000000" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/caratteristica"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/name"
android:layout_toRightOf="#id/chk_box"
android:textStyle="italic" />
</LinearLayout>
<!-- <TextView
android:id="#+id/id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textSize="12sp"
android:textStyle="italic"/>-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/dist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/caratteristica"
android:layout_toRightOf="#id/chk_box"
android:textSize="12sp"
android:textStyle="italic" />
<TextView
android:id="#+id/valuta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textSize="12sp"
android:textStyle="italic" />
</LinearLayout>
<EditText
android:layout_width="196dp"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="#+id/editText"
android:hint="quantità"
>
</EditText>
</LinearLayout>
<ImageView
android:id="#+id/ivImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_gravity="center"
android:src="#mipmap/ic_launcher"
/>
</LinearLayout>

Material Design Layout issue

I am having trouble with Material Design layout.
Here is what I have:
and the code to represent that
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
android:background="#color/backgroundColor"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:showIn="#layout/activity_main"
tools:context="com.mycompany.inventory.MainActivity">
<ImageView
android:id="#+id/logoView"
android:layout_width="225dp"
android:layout_height="90dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="#drawable/mycompanylogo"
android:layout_marginBottom="20dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="USERNAME"
android:id="#+id/txtUsername"
android:layout_below="#+id/logoView"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="0"
android:layout_below="#id/txtUsername"
android:id="#+id/txtScannedCount"/>
<TextView
android:text="Scanned Today"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView"
android:layout_below="#+id/txtScannedCount"
android:layout_alignLeft="#+id/txtScannedCount"
android:layout_alignStart="#+id/txtScannedCount" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="0"
android:id="#+id/txtInventoryCount"
android:layout_below="#id/txtUsername"
android:layout_alignRight="#+id/btnSearch"
android:layout_alignEnd="#+id/btnSearch" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Inventory"
android:id="#+id/textView4"
android:layout_above="#+id/btnSearch"
android:layout_toRightOf="#+id/textView"
android:layout_toEndOf="#+id/textView"
android:layout_marginLeft="153dp"
android:layout_marginStart="153dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/btn_searchvehicle"
android:id="#+id/btnSearch"
android:layout_below="#+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="46dp"
android:layout_marginBottom="15dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:background="#color/colorPrimary"
android:backgroundTint="#color/colorPrimaryDark"
android:textColor="#color/buttontext"
android:onClick="NavSearchVechiclesPressed"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/btn_scanbarcode"
android:id="#+id/btnScanner"
android:layout_below="#+id/btnSearch"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="#+id/btnSearch"
android:layout_alignEnd="#+id/btnSearch"
android:background="#color/colorPrimary"
android:backgroundTint="#color/colorPrimaryDark"
android:textColor="#color/buttontext"
android:onClick="NavScanBarcodePressed"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Small Text"
android:id="#+id/txtVersion"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:textColor="#color/divider"/>
</RelativeLayout>
And through the magic of Photoshop here is what I want.
How can I obtain he lay out with the "Scanned Today" and "Inventory" text views as well as the large centered numbers?
Try this one
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
android:background="#color/backgroundColor"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:showIn="#layout/activity_main"
tools:context="com.mycompany.inventory.MainActivity">
<ImageView
android:id="#+id/logoView"
android:layout_width="225dp"
android:layout_height="90dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="#drawable/mycompanylogo"
android:layout_marginBottom="20dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="USERNAME"
android:id="#+id/txtUsername"
android:layout_below="#+id/logoView"
android:layout_centerHorizontal="true" />
<TextView
android:text="Scanned Today"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:id="#+id/textView"
android:layout_alignLeft="#+id/btnSearch"
android:layout_alignStart="#+id/btnSearch"
android:layout_below="#+id/txtScannedCount" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="0"
android:textSize="30sp"
android:layout_below="#id/txtUsername"
android:gravity="center_horizontal"
android:id="#+id/txtScannedCount"
android:layout_alignLeft="#+id/textView"
android:layout_alignStart="#+id/textView"
android:layout_alignRight="#+id/textView"
android:layout_alignEnd="#+id/textView"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="0"
android:textSize="30sp"
android:gravity="center_horizontal"
android:id="#+id/txtInventoryCount"
android:layout_below="#id/txtUsername"
android:layout_alignLeft="#+id/textView4"
android:layout_alignStart="#+id/textView4"
android:layout_alignRight="#+id/textView4"
android:layout_alignEnd="#+id/textView4" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Inventory"
android:id="#+id/textView4"
android:layout_marginRight="30dp"
android:gravity="center_horizontal"
android:layout_above="#+id/btnSearch"
android:layout_alignRight="#+id/btnSearch"
android:layout_alignEnd="#+id/btnSearch" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/btn_searchvehicle"
android:id="#+id/btnSearch"
android:layout_below="#+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="46dp"
android:layout_marginBottom="15dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:background="#color/colorPrimary"
android:backgroundTint="#color/colorPrimaryDark"
android:textColor="#color/buttontext"
android:onClick="NavSearchVechiclesPressed"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/btn_scanbarcode"
android:id="#+id/btnScanner"
android:layout_below="#+id/btnSearch"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="#+id/btnSearch"
android:layout_alignEnd="#+id/btnSearch"
android:background="#color/colorPrimary"
android:backgroundTint="#color/colorPrimaryDark"
android:textColor="#color/buttontext"
android:onClick="NavScanBarcodePressed"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Small Text"
android:id="#+id/txtVersion"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:textColor="#color/divider"/>
</RelativeLayout>
I think what you want is for the TextView text to be center justified horizontally, in which case add
android:gravity="center_horizontal"
to your textViews
You can (and probably you should) use other layouts inside your parent relativeLayout. This way you simplify a lot the design and you avoid that all the design is dependant of one item (on your layout, if you remove one of the textViews most of the layout is repositioned, as they were relative to that textView)
A quick example of this with your code could be something like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.mycompany.inventory.MainActivity">
<Button
android:id="#+id/btnSearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
android:backgroundTint="#color/colorPrimaryDark"
android:onClick="NavSearchVechiclesPressed"
android:layout_below="#+id/linearLayout3"
android:layout_alignParentStart="true"
android:layout_alignEnd="#+id/linearLayout3"
android:layout_marginTop="50dp" />
<Button
android:id="#+id/btnScanner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/btnSearch"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="#+id/btnSearch"
android:layout_below="#+id/btnSearch"
android:background="#color/colorPrimary"
android:backgroundTint="#color/colorPrimaryDark"
android:onClick="NavScanBarcodePressed"
android:layout_marginTop="20dp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/linearLayout2">
<ImageView
android:id="#+id/logoView"
android:layout_width="225dp"
android:layout_height="90dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:layout_gravity="center_horizontal" />
<TextView
android:id="#+id/txtUsername"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/logoView"
android:layout_centerHorizontal="true"
android:text="USERNAME"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="#+id/linearLayout2"
android:layout_alignParentEnd="true"
android:id="#+id/linearLayout3">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:id="#+id/txtScannedCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/txtUsername"
android:text="0"
android:textSize="50sp"
android:layout_gravity="center_horizontal" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/txtScannedCount"
android:layout_alignStart="#+id/txtScannedCount"
android:layout_below="#+id/txtScannedCount"
android:text="Scanned Today"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:id="#+id/txtInventoryCount"
android:layout_width="wrap_content"
android:textSize="50sp"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/btnSearch"
android:layout_alignRight="#+id/btnSearch"
android:layout_below="#id/txtUsername"
android:text="0"
android:layout_gravity="center_horizontal" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/btnSearch"
android:layout_toEndOf="#+id/textView"
android:layout_toRightOf="#+id/textView"
android:text="Inventory"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_gravity="center_horizontal" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
(I removed the text, colors and images, but it looks similar to what you want)
Try playing around with different sub-layouts and it will make your life easier :)
use layout as
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
android:background="#color/backgroundColor"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:showIn="#layout/activity_main"
tools:context="com.mycompany.inventory.MainActivity">
<ImageView
android:id="#+id/logoView"
android:layout_width="225dp"
android:layout_height="90dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="#drawable/mycompanylogo"
android:layout_marginBottom="20dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="USERNAME"
android:id="#+id/txtUsername"
android:layout_below="#+id/logoView"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/btn_searchvehicle"
android:id="#+id/btnSearch"
android:layout_below="#+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="46dp"
android:layout_marginBottom="15dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:background="#color/colorPrimary"
android:backgroundTint="#color/colorPrimaryDark"
android:textColor="#color/buttontext"
android:onClick="NavSearchVechiclesPressed"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/btn_scanbarcode"
android:id="#+id/btnScanner"
android:layout_below="#+id/btnSearch"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="#+id/btnSearch"
android:layout_alignEnd="#+id/btnSearch"
android:background="#color/colorPrimary"
android:backgroundTint="#color/colorPrimaryDark"
android:textColor="#color/buttontext"
android:onClick="NavScanBarcodePressed"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Small Text"
android:id="#+id/txtVersion"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:textColor="#color/divider"/>
<TextView
android:id="#+id/txtInventoryCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView4"
android:layout_alignEnd="#+id/btnSearch"
android:layout_toRightOf="#+id/logoView"
android:text="0"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/txtScannedCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/txtUsername"
android:layout_toLeftOf="#+id/logoView"
android:text="0"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignStart="#+id/txtScannedCount"
android:layout_below="#+id/txtScannedCount"
android:text="Scanned Today" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/btnSearch"
android:layout_alignParentRight="true"
android:layout_marginStart="153dp"
android:layout_toEndOf="#+id/textView"
android:text="Inventory"
android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>

OnTouch listener not working in relativelayout which included mapfragment

in fragment i need to implement ontouch listener to relativelayout which included map fragment and i have made layouts as when i click map button mapview visible, same as done with listview. i have to detect when user touch over map, also i made ontouch for partmap layout which doesn't work.anyone plz.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/partMap"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:focusable="true"
android:focusableInTouchMode="true"
android:clickable="true"
android:layout_above="#+id/footer"
android:alpha="0.0">
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment" />
<RelativeLayout
android:id="#+id/R_noPropertiesMatchMap"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_above="#+id/footer"
android:layout_marginTop="5dp"
android:alpha="0.5"
android:background="#000000"
android:padding="10dp"
android:visibility="gone" >
<TextView
android:id="#+id/tv1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="No properties match your search"
android:textColor="#FFFFFF"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tv2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/tv1"
android:gravity="center_horizontal"
android:text="Please change the zoom or your filters"
android:textColor="#FFFFFF"
android:textSize="14sp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/R_noOnlyUS"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:layout_above="#+id/footer"
android:alpha="0.5"
android:background="#000000"
android:padding="10dp"
android:visibility="gone">
<TextView
android:id="#+id/tv3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Invalid address"
android:textColor="#FFFFFF"
android:textSize="14sp"
android:textStyle="bold"
/>
<TextView
android:id="#+id/tv4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/tv3"
android:gravity="center_horizontal"
android:text="Realy is only available in the US"
android:textColor="#FFFFFF"
android:textSize="14sp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/R_notgeoloc"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:alpha="0.5"
android:background="#000000"
android:layout_above="#+id/footer"
android:padding="10dp"
android:visibility="gone" >
<TextView
android:id="#+id/tv3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Oops! We are unable to find your location."
android:textColor="#FFFFFF"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tv4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/tv3"
android:gravity="center_horizontal"
android:text="Please check your system preferences to make sure geolocation is enabled."
android:textColor="#FFFFFF"
android:textSize="14sp"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>`<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/partone"
android:layout_above="#+id/footer"
>
<ListView
android:id="#+id/lv_listing"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:divider="#null"
android:drawSelectorOnTop="true"
android:scrollbars="none"
/>
<ProgressBar
android:id="#+id/R_Loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/footer"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:visibility="gone"/>
<LinearLayout
android:id="#+id/L_no_fav_homes"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_above="#+id/footer"
android:orientation="vertical"
android:paddingTop="30dp"
android:visibility="gone"
android:weightSum="10" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="8" >
<ImageView
android:id="#+id/iv_no_fav_homes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:contentDescription="#string/app_name"
android:src="#drawable/no_homes" />
<TextView
android:id="#+id/tv_fav_properties"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/iv_no_fav_homes"
android:layout_margin="10dp"
android:gravity="center_horizontal"
android:text="No properties match your search"
android:textColor="#78797B"
android:textSize="20sp" />
<TextView
android:id="#+id/tv_facebookmessage"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/tv_fav_properties"
android:layout_margin="10dp"
android:gravity="center_horizontal"
android:text="Please change your filters"
android:textColor="#ADAEB0"
android:textSize="18sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2" >
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/L_out_us"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_above="#+id/footer"
android:paddingTop="30dp"
android:visibility="gone"
android:weightSum="10" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="8" >
<ImageView
android:id="#+id/iv_no_us"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:contentDescription="#string/app_name"
android:src="#drawable/out_usa" />
<TextView
android:id="#+id/text_error"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/iv_no_us"
android:layout_margin="10dp"
android:gravity="center_horizontal"
android:text="Invalid address"
android:textColor="#78797B"
android:textSize="20sp" />
<TextView
android:id="#+id/text_error_2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/text_error"
android:layout_margin="10dp"
android:gravity="center_horizontal"
android:text="Realy is only available in the US"
android:textColor="#ADAEB0"
android:textSize="18sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2" >
<Button
android:id="#+id/tv_startsearching_clear"
style="#style/btnStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_margin="8dp"
android:layout_marginTop="100dp"
android:gravity="center"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="Clear filter"
android:textColor="#ffffff"
android:textSize="20sp"
android:visibility="gone" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/L_notgeoloc"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_above="#+id/footer"
android:paddingTop="30dp"
android:visibility="gone"
android:weightSum="10" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:layout_gravity="center_horizontal"
android:contentDescription="#string/app_name"
android:src="#drawable/notgeoloc" />
<TextView
android:id="#+id/text_error45"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/iv_no_us"
android:layout_margin="10dp"
android:gravity="center_horizontal"
android:text="Oops! We are unable to find your location."
android:textColor="#78797B"
android:textSize="20sp" />
<TextView
android:id="#+id/text_error_3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/text_error"
android:layout_margin="10dp"
android:gravity="center_horizontal"
android:text="Please check your system preferences to make sure geolocation is enabled."
android:textColor="#ADAEB0"
android:textSize="18sp" />
</LinearLayout>
<FrameLayout
android:id="#+id/Footer"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:background="#006AA8"
android:orientation="horizontal"
android:layout_gravity="center_horizontal|bottom">
<TextView
android:id="#+id/ShowMap"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="10dp"
android:gravity="center"
android:clickable="true"
android:text="Map"
android:textColor="#FFFFFF"
android:textSize="16sp"
android:layout_gravity="right|center_vertical" />
<TextView
android:id="#+id/ShowNearby"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="10dp"
android:gravity="center"
android:text="Nearby"
android:clickable="true"
android:textColor="#FFFFFF"
android:textSize="16sp"
android:layout_gravity="left|center_vertical" />
<TextView
android:id="#+id/ClearFilters"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="10dp"
android:gravity="center"
android:text="Clear filters"
android:clickable="true"
android:textColor="#FFFFFF"
android:textSize="16sp"
android:visibility="gone"
android:layout_gravity="center" />
</FrameLayout>
</FrameLayout></RelativeLayout>`

FrameLayout: View Arrrangement and Null Pointer Exception

The main highlight of my activity is the image in the center, that can be zoom in up to the whole screen. Right now, The positions are okay but in some point of zooming in the image two of the textview are being covered by the image, the rest of the view remains at the top of the image.
So my main problem is to put the two textview at the top of the image. I tried transferring the positions of each of the view in xml but for some reason I got null pointer exception.
xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:gravity="center" >
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView1"
android:layout_marginTop="20dp"
android:textColor="#FF4F00"
android:textSize="20sp"
android:alpha=".5"
android:text="Name" />
<TextView
android:id="#+id/txtPid"
android:layout_below="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:textColor="#FF4F00"
android:textSize="20sp"
android:layout_marginTop="20dp"
android:alpha=".5"
android:text="Category Or PID" />
<ImageView
android:id="#+id/iv_photo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:scaleType="center" />
<TextView
android:id="#+id/txtItemNo"
android:layout_below="#+id/txtSellingPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="19dp"
android:textColor="#FF4F00"
android:textSize="20sp"
android:alpha=".5"
android:text="Item No" />
<TextView
android:id="#+id/txtSellingPrice"
android:layout_below="#+id/txtPid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="20dp"
android:textColor="#FF4F00"
android:textSize="20sp"
android:alpha=".5"
android:text="Selling Price" />
</RelativeLayout>
</FrameLayout>
Change the relative layout item ordering so that the imageview is the first item. Items are layout and drawn in the order of they appearance.
Try out as below:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center" >
<RelativeLayout
android:id="#+id/rl"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="#+id/layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:orientation="vertical" >
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="20dp"
android:alpha=".5"
android:text="Name"
android:textColor="#FF4F00"
android:textSize="20sp" />
<TextView
android:id="#+id/txtPid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/txtName"
android:layout_marginTop="20dp"
android:alpha=".5"
android:text="Category Or PID"
android:textColor="#FF4F00"
android:textSize="20sp" />
<TextView
android:id="#+id/txtItemNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/txtSellingPrice"
android:layout_marginTop="19dp"
android:alpha=".5"
android:text="Item No"
android:textColor="#FF4F00"
android:textSize="20sp" />
<TextView
android:id="#+id/txtSellingPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/txtPid"
android:layout_marginTop="20dp"
android:alpha=".5"
android:text="Selling Price"
android:textColor="#FF4F00"
android:textSize="20sp" />
</LinearLayout>
<ImageView
android:id="#+id/iv_photo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_toRightOf="#+id/layout"
android:background="#drawable/selctor"
android:scaleType="center" />
</RelativeLayout>
</FrameLayout>
OutPut:

Categories

Resources