Thanks at all for all your help for now.I have another little issues
This is a portion of my layout which give me some problems:
<RelativeLayout android:id="#+id/card_address_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
>
<TextView
style="#style/card_field"
android:id="#+id/card_indirizzo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="left|center_vertical"
android:layout_marginTop="8dp"
android:maxLength="35"
android:ellipsize="marquee"
/>
<ImageButton
android:id="#+id/card_address_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:layout_toRightOf="#id/card_indirizzo"
android:src="#drawable/map_selector"
android:onClick="startMap"
android:padding="0dp" />
</RelativeLayout>
The image button src is a selector, in this case this one:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="#drawable/map_b" /> <!-- pressed -->
<item android:drawable="#drawable/map_a" /> <!-- default -->
This is the result and I really don't understand why, why the image button has padding??!!!
Help meeeee!
This is the FULL xml:
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView android:id="#+id/card_images_horizontalscroll"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:scrollbars="none"
android:visibility="invisible"
>
<LinearLayout android:id="#+id/card_images_layout"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:layout_marginRight="4dp"
>
</LinearLayout>
</HorizontalScrollView>
<TextView
android:id="#+id/card_images_footer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:background="#drawable/click_it"
/>
<ScrollView android:id="#+id/card_data_verticalscroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
>
<LinearLayout android:id="#+id/main_vertical_scroll_layout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
style="#style/card_title"
android:id="#+id/card_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:layout_weight="1"
/>
<TextView
style="#style/card_category"
android:id="#+id/card_categoria"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:layout_marginBottom="30dp"
/>
<RelativeLayout android:id="#+id/card_address_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
>
<TextView
style="#style/card_field"
android:id="#+id/card_indirizzo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="left|center_vertical"
android:layout_marginTop="8dp"
android:maxLength="35"
android:ellipsize="marquee"
/>
<ImageButton
android:id="#+id/card_address_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:layout_toRightOf="#id/card_indirizzo"
android:src="#drawable/map_selector"
android:onClick="startMap"
android:padding="0dp" />
</RelativeLayout>
<RelativeLayout android:id="#+id/card_phone_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
>
<TextView
style="#style/card_field"
android:id="#+id/card_telefono"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:maxLength="35"
android:ellipsize="marquee"
android:layout_gravity="center_vertical"
android:layout_marginTop="8dp"
/>
<ImageButton android:text="call"
android:id="#+id/card_telefono_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_gravity="right|center_vertical"
android:src="#drawable/call_selector"
android:onClick="startCall"
/>
</RelativeLayout>
<RelativeLayout android:id="#+id/card_mail_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
>
<TextView
style="#style/card_field"
android:id="#+id/card_mail"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:maxLength="35"
android:ellipsize="marquee"
android:layout_gravity="center_vertical"
android:layout_marginTop="8dp"
/>
<ImageButton android:text="mail"
android:id="#+id/card_mail_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_gravity="right|center_vertical"
android:onClick="startMailClient"
android:src="#drawable/mail_selector"
/>
</RelativeLayout>
<RelativeLayout android:id="#+id/card_www_layout"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
>
<TextView
style="#style/card_field"
android:id="#+id/card_www"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:maxLength="35"
android:ellipsize="marquee"
android:layout_gravity="center_vertical"
android:layout_marginTop="8dp"
/>
<ImageButton android:text="www"
android:id="#+id/card_www_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_gravity="right|center_vertical"
android:onClick="startDefaultBrowser"
android:src="#drawable/www_selector"
/>
</RelativeLayout>
<TextView
style="#style/card_description"
android:id="#+id/card_descrizione"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false"
android:layout_marginTop="30dp"
/>
</LinearLayout>
</ScrollView>
pedro , just change android:src="#drawable/map_selector" to android:background="#drawable/map_selector"
& you are done!
Related
I want to achieve like the image below
And I tried, but it is not my desired result.
Below is my xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dip">
<LinearLayout android:id="#+id/thumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="3dp"
android:layout_alignParentLeft="true"
android:layout_marginRight="5dip">
<ImageView
android:id="#+id/photo"
android:layout_width="70dp"
android:layout_height="70dp"
android:scaleType="centerCrop"
android:layout_gravity="center"/>
</LinearLayout>
<TextView
android:id="#+id/ListDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/input_register"
android:text="Date"
android:layout_marginLeft="150dp"
android:layout_alignTop="#+id/thumbnail"
android:layout_toRightOf="#+id/thumbnail" />
<TextView
android:id="#+id/ListDescription"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textSize="20sp"
android:text="Description"
android:ellipsize="end"
android:textStyle="bold"
android:layout_below="#id/ListDate"
android:layout_toRightOf="#+id/thumbnail" />
<TextView
android:id="#+id/ListAmount"
android:text="Amount"
android:layout_marginTop="40dp"
android:layout_marginLeft="166dp"
android:textSize="20sp"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:layout_toRightOf="#+id/thumbnail"
android:textColor="#color/violetred" />
</RelativeLayout>
How can I write the ... beside the Amount TextView same like the first image I post ? Any help is much appreciated.
You can have only one layout which will solve your problem nesting is not a good idea.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#mipmap/ic_launcher"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textColor="#000"
android:layout_gravity="center"
android:textSize="?android:actionBarItemBackground"
android:textStyle="bold"
android:text="8 hours # $80.00/hour"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:text="2014-05-08"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/activity_horizontal_margin"
android:textStyle="bold"
android:layout_gravity="end"
android:textColor="#000"
android:textSize="?android:actionBarItemBackground"
android:text="$640.00"/>
</FrameLayout>
you can achieve your requirement with this xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#d8d8d8" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="85dp"
android:layout_height="85dp"
android:background="#c8c8c8"
android:src="#drawable/ic_launcher" >
</ImageView>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/imageView1"
android:text="TextView"
android:textColor="#000000" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="6dp"
android:layout_marginTop="20dp"
android:padding="2dp"
android:text="2014-05-08"
android:textColor="#000000" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/textView2"
android:layout_marginRight="6dp"
android:layout_marginTop="20dp"
android:padding="2dp"
android:text="$600"
android:textColor="#000000"
android:textStyle="bold" />
</RelativeLayout>
hope this helps you.exact xml of you want to achieve.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dip">
<ImageView
android:id="#+id/photo"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_margin="5dp"
android:padding="3dp"
android:scaleType="centerCrop"
android:layout_gravity="center"/>
<TextView
android:id="#+id/ListDescription"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/right_container"
android:singleLine="true"
android:textSize="20sp"
android:text="Description"
android:ellipsize="end"
android:textStyle="bold"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/photo" />
<LinearLayout
android:id="#+id/right_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:orientation="vertical">
<TextView
android:id="#+id/ListDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#color/input_register"
android:text="12-11-2017"
android:layout_marginRight="10dp"/>
<TextView
android:id="#+id/ListAmount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="777$"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:textSize="20sp"
android:textColor="#color/violetred" />
</LinearLayout>
Use constraint layout for best performance. If not, use horizontal linear layout, with weight on the center one.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="5dip">
<ImageView
android:id="#+id/photo"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:background="#color/black"
android:scaleType="centerCrop" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="1"
android:ellipsize="end"
android:gravity="center_vertical"
android:lines="1"
android:text="Buy drinks fvbfvfvfvasdasdasdfvfvvfvf" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="1014-05-08" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="$6969"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#mipmap/ic_launcher" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1.5"
android:ellipsize="end"
android:maxLines="1"
android:text="ASASJHGHHBHHJHJNKMKIKMKMKMKMKKNIKNIJ" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="2016-01-11" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="$640"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
try this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1"
android:padding="5dip">
<LinearLayout android:id="#+id/thumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="3dp"
android:weightSum=".20"
android:layout_alignParentLeft="true"
android:layout_marginRight="5dip">
<ImageView
android:id="#+id/photo"
android:layout_width="70dp"
android:layout_height="70dp"
android:scaleType="centerCrop"
android:layout_gravity="center"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum=".80"
android:layout_alignRight="#+id/thumbnail"
android:layout_alignParentRight="true"
android:orientation="vertical">
<TextView
android:id="#+id/ListDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginRight="10dp"
android:textColor="#color/input_register"
android:text="Date"
/>
<TextView
android:id="#+id/ListDescription"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:layout_marginRight="10dp"
android:textSize="20sp"
android:text="DescriptionDescriptionDescriptionDescription"
android:ellipsize="end"
android:textStyle="bold"
/>
<TextView
android:id="#+id/ListAmount"
android:text="Amount"
android:textSize="20sp"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="end"
android:layout_marginRight="10dp"
android:layout_toRightOf="#+id/thumbnail"
android:textColor="#color/violetred" />
</LinearLayout>
</LinearLayout>
I have a listview with edittext as row items inside scrollview.I have used on touch listener on listview so I can scroll the list inside scrollview.But unable to make a call to onItemClickListener or OnItemSelectedListener.
I have tried android:windowSoftInputMode="adjustPan".
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="#+id/rlHamburger"
android:layout_width="50dp"
android:layout_height="match_parent" >
<Button
android:id="#+id/btnHamburger"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_centerInParent="true"
android:background="#drawable/images" />
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="#+id/rlHamburger" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="#+id/rlTitle"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="5dp"
android:background="#drawable/relative_background" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:text="Add Quote"
android:textColor="#color/black"
android:textSize="20sp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/rlButtons"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="#id/rlTitle"
android:layout_margin="5dp"
android:orientation="horizontal" >
<Button
android:id="#+id/btnBack"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#drawable/button"
android:gravity="center"
android:text="Back"
android:textColor="#drawable/text_color" />
<Button
android:id="#+id/btnAddPhoto"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:layout_toLeftOf="#+id/btnAddNote"
android:layout_weight="1"
android:background="#drawable/button"
android:gravity="center"
android:text="Add Photo"
android:textColor="#drawable/text_color" />
<Button
android:id="#+id/btnAddNote"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:layout_toLeftOf="#+id/btnSave"
android:layout_weight="1"
android:background="#drawable/button"
android:gravity="center"
android:text="Add Note"
android:textColor="#drawable/text_color" />
<Button
android:id="#+id/btnSave"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#drawable/button"
android:gravity="center"
android:text="Save"
android:textColor="#drawable/text_color" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/rlInformation"
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_below="#id/rlButtons"
android:layout_margin="5dp"
android:background="#drawable/relative_background"
android:orientation="horizontal"
android:padding="5dp" >
<RelativeLayout
android:id="#+id/rlInfo1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp" >
<TextView
android:id="#+id/title"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="Title" />
<EditText
android:id="#+id/tvTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/title"
android:background="#drawable/relative_background"
android:hint="Title"
android:padding="5dp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/rlInfo2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/rlInfo1"
android:layout_margin="2dp" >
<TextView
android:id="#+id/owner"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="Owner" />
<EditText
android:id="#+id/tvOwner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/owner"
android:background="#drawable/relative_background"
android:hint="Owner"
android:padding="5dp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/rlInfo3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/rlInfo2"
android:layout_margin="2dp" >
<TextView
android:id="#+id/address"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="Address" />
<EditText
android:id="#+id/tvAddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/address"
android:background="#drawable/relative_background"
android:hint="Address"
android:padding="5dp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/rlInfo4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/rlInfo3"
android:layout_margin="2dp" >
<TextView
android:id="#+id/status"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="Status" />
<TextView
android:id="#+id/tvStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="#id/status"
android:text="Status" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/rlInfo5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/rlInfo4"
android:layout_margin="2dp" >
<TextView
android:id="#+id/description"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="Description" />
<EditText
android:id="#+id/tvDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/description"
android:background="#drawable/relative_background"
android:hint="Description"
android:padding="5dp" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/rlList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/rlInformation"
android:layout_margin="10dp" >
<TextView
android:id="#+id/tvProductName"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Product Name" />
<TextView
android:id="#+id/tvShortDescription"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/tvProductName"
android:gravity="center"
android:text="Short Description" />
<TextView
android:id="#+id/tvQuantity"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/tvShortDescription"
android:gravity="center"
android:text="Qty" />
<TextView
android:id="#+id/tvUnits"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/tvQuantity"
android:gravity="center"
android:text="units" />
<TextView
android:id="#+id/tvPrice"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/tvUnits"
android:gravity="center"
android:text="Price" />
<TextView
android:id="#+id/tvTotal"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:gravity="center"
android:text="Total" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/rlList1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/rlList"
android:layout_margin="10dp" >
<ListView
android:id="#+id/lvItems"
android:layout_width="match_parent"
android:layout_height="300dp" >
</ListView>
<Button
android:id="#+id/btnAddItem"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_below="#id/lvItems"
android:background="#drawable/button"
android:text="Add item"
android:textColor="#drawable/text_color" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/rlList1"
android:layout_margin="20dp" >
<TextView
android:id="#+id/tvTotalEstimation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:gravity="center"
android:text="Total estimation"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tvEstimationValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#id/tvTotalEstimation"
android:gravity="center"
android:text="$0.0"
android:textSize="20sp"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Here is the screenshot of my layout:
Please help me with the solution.Thanks.
Go to your manifest file and add these steps with activity tag of your class
android:configChanges="keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden"
Android - How can I align the text to the center , the left texviews ¨t¨and ¨c¨should be align with the center of the imageview and the right textview ¨localTime" , why are they on top ?
Thanks Stackoverflow
Heres a pic of my layout , can see the difference ?
<LinearLayout
android:id="#+id/LinearLayout_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:weightSum="3.0" >
<TextView
android:id="#+id/localTimestamp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:gravity="left|center_vertical"
android:text="localTime"
/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:gravity="right|bottom"
android:weightSum="1.0" >
<TextView
android:id="#+id/weather"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible"
android:gravity="right|bottom"
android:text="w"
android:textColor="#FFFFFF"/>
<ImageView
android:id="#+id/ic_weather"
android:layout_width="25dip"
android:layout_height="25dip"
android:layout_toRightOf="#+id/weather"
android:background="#drawable/w_1"
android:contentDescription="#string/todo"
android:gravity="right|bottom" />
<TextView
android:id="#+id/temperature"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/ic_weather"
android:gravity="right|bottom"
android:text="#string/t"
/>
<TextView
android:id="#+id/unitTemp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right|bottom"
android:layout_toRightOf="#+id/temperature"
android:text="#string/c"
/>
</RelativeLayout>
</LinearLayout>
add
android:layout_centerVertical="true"
for both of textviews
<TextView
android:id="#+id/temperature"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/ic_weather"
android:gravity="right|bottom"
android:layout_centerVertical="true"
android:text="t" />
<TextView
android:id="#+id/unitTemp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/temperature"
android:gravity="right|bottom"
android:layout_centerVertical="true"
android:text="c" />
Try this way,hope this will help you to solve your problem.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/LinearLayout_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp">
<TextView
android:id="#+id/localTimestamp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="localTime"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:gravity="center"
android:layout_marginLeft="5dp">
<TextView
android:id="#+id/weather"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:visibility="invisible"
android:gravity="right|bottom"
android:text="w"
android:textColor="#FFFFFF"/>
<ImageView
android:id="#+id/ic_weather"
android:layout_width="25dp"
android:layout_height="25dp"
android:background="#drawable/w_1"
android:layout_marginLeft="5dp"
android:contentDescription="#string/todo"/>
<TextView
android:id="#+id/temperature"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="#string/t"/>
<TextView
android:id="#+id/unitTemp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="#string/c"/>
</LinearLayout>
</LinearLayout>
I think #Haresh is right. I am using almost same. Just remove string.
My xml code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >
<LinearLayout
android:id="#+id/LinearLayout_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:weightSum="3.0" >
<TextView
android:id="#+id/localTimestamp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:gravity="left|center_vertical"
android:text="localTime" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:gravity="right|bottom"
android:weightSum="1.0" >
<TextView
android:id="#+id/weather"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right|bottom"
android:text="w"
android:textColor="#FFFFFF"
android:visibility="invisible" />
<ImageView
android:id="#+id/ic_weather"
android:layout_width="25dip"
android:layout_height="25dip"
android:layout_toRightOf="#+id/weather"
android:gravity="right|bottom" />
<TextView
android:id="#+id/temperature"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/ic_weather"
android:gravity="right|bottom" />
<TextView
android:id="#+id/unitTemp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/temperature"
android:gravity="right|bottom" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
I am trying to create the following layout in android.
I am unable to achieve the layout as shown in the image.Please ignore the image on the extreme left.
<LinearLayout
android:id="#+id/ll_groups_list_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_weight="1.0"
android:background="#drawable/normal_white_bg"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/groups_list_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="Group name"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/groups_list_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:text="Group Description may come for two lines" />
</LinearLayout>
<ImageView
android:id="#+id/groups_list_image"
android:layout_width="70dp"
android:layout_height="70dp"
android:padding="3dip"
android:src="#drawable/logo" />
this may helpful to you,
<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="2dp" >
<ImageView
android:id="#+id/image"
android:layout_width="120dp"
android:layout_height="120dp"
android:contentDescription="#string/news" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_toLeftOf="#+id/arrow"
android:layout_toRightOf="#+id/thumb"
android:orientation="vertical" >
<TextView
android:id="#+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:text="#string/text1"
android:textSize="25dp"
android:textStyle="bold" />
<TextView
android:id="#+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginTop="25dp"
android:padding="2dp"
android:paddingTop="20dp"
android:text="#string/text2"
android:textColor="#7F7F7F"
android:textSize="10sp" />
</RelativeLayout>
<ImageView
android:id="#+id/textImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:src="#drawable/image_source" />
</RelativeLayout>
Try this way,hope this will help you to solve your problem.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFF00"
android:padding="5dp">
<LinearLayout
android:id="#+id/ll_groups_list_text"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:gravity="center_vertical"
android:padding="5dp">
<TextView
android:id="#+id/groups_list_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="Group name"
android:textColor="#000000"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/groups_list_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:textColor="#000000"
android:layout_marginTop="5dp"
android:text="Group Description may come for two lines" />
</LinearLayout>
<ImageView
android:id="#+id/groups_list_image"
android:layout_width="70dp"
android:layout_height="70dp"
android:padding="3dip"
android:background="#FFFFFF"
android:src="#drawable/ic_launcher" />
</LinearLayout>
Please use this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFF00"
android:padding="2dp" >
<RelativeLayout
android:id="#+id/ll_groups_list_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="#FFFFFF"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignTop="#+id/imageView1"
android:text="Text1"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/imageView1"
android:layout_alignParentLeft="true"
android:text="Text 2"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="#drawable/ic_launcher" />
</RelativeLayout>
</LinearLayout>
I'm trying to integrate a color bar like example below in my XML file which is currently working properply only integrating this colored vertical bar is making it difficult.
My custom listview adapterview which works without any color bar
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="4dp" >
<TextView
android:id="#+id/subject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold" />
<TextView
android:id="#+id/relation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/default_green"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/ticketDepartmentName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#999999"
android:textSize="14sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/ticketDueDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/color_transparent"
android:gravity="center_horizontal"
android:textColor="#color/red"
android:textStyle="bold" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/priority"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_marginRight="3dp"
android:layout_toLeftOf="#id/status"
android:background="#drawable/default_button"
android:gravity="center_horizontal"
android:textColor="#ffffff" />
<TextView
android:id="#+id/status"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#drawable/salesdesk_button"
android:gravity="center_horizontal"
android:textColor="#ffffff" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
I succeeded for let us say 50% to make it work with a textview but it's not how it should be. Here the code I got after a while.
<?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"
android:orientation="vertical" >
<TextView
android:id="#+id/colorBar"
android:layout_width="4dp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:background="#drawable/default_button" />
<TextView
android:id="#+id/subject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/colorBar"
android:textStyle="bold" />
<TextView
android:id="#+id/relation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/subject"
android:layout_toRightOf="#id/colorBar"
android:textColor="#color/default_green"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/ticketDepartmentName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/relation"
android:layout_toRightOf="#id/colorBar"
android:textColor="#999999"
android:textSize="14sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/ticketDueDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/color_transparent"
android:gravity="center_horizontal"
android:textColor="#color/red"
android:textStyle="bold" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/priority"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_marginRight="3dp"
android:layout_toLeftOf="#id/status"
android:background="#drawable/default_button"
android:gravity="center_horizontal"
android:textColor="#ffffff" />
<TextView
android:id="#+id/status"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#drawable/default_button"
android:gravity="center_horizontal"
android:textColor="#ffffff" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
This looks like so As you can see the colored bar stops in the middle I have no idea why and my last Relative and Linearlayout get messed up. Please help, thanks in advance!
Try this..
<?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="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/colorBar"
android:layout_width="4dp"
android:layout_height="match_parent"
android:background="#478848" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/subject"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text1"
android:textStyle="bold" />
<TextView
android:id="#+id/relation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text2"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/ticketDepartmentName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text3"
android:textColor="#999999"
android:textSize="14sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/ticketDueDate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="Text4"
android:textStyle="bold" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:orientation="horizontal" >
<TextView
android:id="#+id/priority"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#F89407"
android:gravity="center"
android:text="priority"
android:textColor="#ffffff" />
<TextView
android:id="#+id/status"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#478948"
android:gravity="center"
android:text="status"
android:textColor="#ffffff" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>