I'm using this layout in one of my applications. I don't know why it is getting distorted. The main issue is that in all the three LinearLayout blocks, only the first TextView is displayed on the screen and in place of the TextViews following that, a big blank space is displayed.
The snapshot of the image being displayed is Snapshot...
Layout.xml
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5sp" >
<LinearLayout
android:id="#+id/ll_images"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:orientation="vertical"
android:padding="10sp" >
<ImageView
android:id="#+id/certification_image"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:contentDescription="#string/details_image"
android:visibility="gone" />
<ImageView
android:id="#+id/image_details_page"
android:layout_width="100sp"
android:layout_height="100sp"
android:contentDescription="#string/details_image" />
</LinearLayout>
<TextView
android:id="#+id/details_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#id/ll_images"
android:padding="10sp"
android:textColor="#040404"
android:textSize="25sp"
android:textStyle="bold"
android:typeface="sans" />
<TextView
android:id="#+id/details_tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/details_name"
android:layout_toLeftOf="#id/ll_images"
android:paddingLeft="5sp"
android:textColor="#343434"
android:textSize="15sp"
android:typeface="sans" />
<LinearLayout
android:id="#+id/ll_facts"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/ll_images">
<TextView
android:id="#+id/tv_facts"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/gradient_bg"
android:padding="10sp"
android:text="Facts"
android:textColor="#android:color/darker_gray"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/details_tv2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5sp"
android:textSize="15sp"
android:text="#string/test" />
<TextView
android:id="#+id/details_tv3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5sp"
android:text="#string/test"
android:textSize="15sp" />
<TextView
android:id="#+id/details_tv4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5sp"
android:text="#string/test"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_foundation"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/ll_facts">
<TextView
android:id="#+id/tv_foundation"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/gradient_bg"
android:padding="10sp"
android:text="Foundation Statement"
android:textColor="#android:color/darker_gray"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/details_tv5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5sp"
android:textColor="#343434"
android:text="#string/test"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_overview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/ll_foundation">
<TextView
android:id="#+id/tv_overview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/gradient_bg"
android:padding="10sp"
android:text="Overview"
android:textColor="#android:color/darker_gray"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/details_tv6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/test"
android:paddingLeft="5sp"
android:textColor="#343434"
android:textSize="15sp" />
</LinearLayout>
<Button
android:id="#+id/btnViewScorecard"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/ll_overview"
android:layout_margin="5sp"
android:background="#drawable/search_button"
android:paddingLeft="10sp"
android:text="#string/ViewScorecard"
android:textColor="#FFFFFF"
android:typeface="sans"
android:visibility="gone"/>
</RelativeLayout>
Any help would be really appreciated. Thanks in advance!!!
You forget about
xmlns:android="http://schemas.android.com/apk/res/android"
Just change
<RelativeLayout
to
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
Finally I have figured it out... All I had to do was I had to add the following line to my LinearLayout.
android:orientation="vertical"
Thanks all for the help...
Related
Sometimes my ScrollView hasn't enough content to be scrolled. Now I want the Overscroll animation enabled even when nothing was scrolled- to tell my users its the end of the page.
android:overScrollMode="always" does nothing...
My layout xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:overScrollMode="always">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/event1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#mipmap/event_back1">
<TextView
android:id="#+id/koteret1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/kav1"
android:layout_centerHorizontal="true"
android:text="Title"
android:textSize="40dp" />
<View
android:id="#+id/kav1"
android:layout_width="200dp"
android:layout_height="1dp"
android:layout_above="#+id/date1"
android:layout_centerHorizontal="true"
android:background="#FFFFFF" />
<TextView
android:id="#+id/date1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="date"
android:textColor="#color/accent_material_light"
android:textSize="30dp" />
<TextView
android:id="#+id/time1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/date1"
android:layout_centerHorizontal="true"
android:text="time"
android:textColor="#color/accent_material_light"
android:textSize="30dp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/event2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#mipmap/event_back2">
<TextView
android:id="#+id/koteret2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/kav2"
android:layout_centerHorizontal="true"
android:text="Title"
android:textSize="40dp" />
<View
android:id="#+id/kav2"
android:layout_width="200dp"
android:layout_height="1dp"
android:layout_above="#+id/date2"
android:layout_centerHorizontal="true"
android:background="#FFFFFF" />
<TextView
android:id="#+id/date2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="date"
android:textColor="#color/accent_material_light"
android:textSize="30dp" />
<TextView
android:id="#+id/time2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/date2"
android:layout_centerHorizontal="true"
android:text="time"
android:textColor="#color/accent_material_light"
android:textSize="30dp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/event3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#mipmap/event_back3">
<TextView
android:id="#+id/koteret3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/kav3"
android:layout_centerHorizontal="true"
android:text="Title"
android:textSize="40dp" />
<View
android:id="#+id/kav3"
android:layout_width="200dp"
android:layout_height="1dp"
android:layout_above="#+id/date3"
android:layout_centerHorizontal="true"
android:background="#FFFFFF" />
<TextView
android:id="#+id/date3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="date"
android:textColor="#color/accent_material_light"
android:textSize="30dp" />
<TextView
android:id="#+id/time3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/date3"
android:layout_centerHorizontal="true"
android:text="time"
android:textColor="#color/accent_material_light"
android:textSize="30dp" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
and it looks like this:
Please notice I want it exactly like this and not in ListView.
Thank you :)
I have item_list.xml of ListView in side of Activity
Layout shown perfect in Graphical Layout
here put item_list.xml
<?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:background="#5F8295" >
<LinearLayout
android:id="#+id/imageview"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:gravity="center_vertical"
android:orientation="vertical" >
<ImageView
android:id="#+id/mImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/android_launcher" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/compliance"
android:layout_toRightOf="#+id/imageview"
android:orientation="vertical" >
<TextView
android:id="#+id/txtTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:singleLine="true"
android:text="TITLE"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#fff"
android:textSize="30sp" />
<TextView
android:id="#+id/txtNoofTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:singleLine="true"
android:text="Text"
android:textColor="#fff"
android:textSize="18sp" />
<TextView
android:id="#+id/txtDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:singleLine="true"
android:text="Other Details for User"
android:textColor="#fff"
android:textSize="18sp" />
<TextView
android:id="#+id/txtExtraDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="5dp"
android:singleLine="true"
android:text="Extra Description"
android:textColor="#fff"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/compliance"
android:layout_width="10dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:background="#FF0000"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/empty" // transparent png image 10x10
/>
</LinearLayout>
</RelativeLayout>
It shown in screen as per below image
I want output as per below image
I dont understand why my color layout not showing its height = "match_parent"
change your layout to some thing like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/rightBg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FF0000" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:background="#5F8295" >
<LinearLayout
android:id="#+id/imageview"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:gravity="center_vertical"
android:orientation="vertical" >
<ImageView
android:id="#+id/mImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/compliance"
android:layout_toRightOf="#+id/imageview"
android:orientation="vertical" >
<TextView
android:id="#+id/txtTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:singleLine="true"
android:text="TITLE"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#fff"
android:textSize="30sp" />
<TextView
android:id="#+id/txtNoofTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:singleLine="true"
android:text="Text"
android:textColor="#fff"
android:textSize="18sp" />
<TextView
android:id="#+id/txtDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:singleLine="true"
android:text="Other Details for User"
android:textColor="#fff"
android:textSize="18sp" />
<TextView
android:id="#+id/txtExtraDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="5dp"
android:singleLine="true"
android:text="Extra Description"
android:textColor="#fff"
android:textSize="18sp" />
</LinearLayout>
</RelativeLayout>
you need to change background color of rightBg id in your getView() method
result:
I have made a simple form in android and have put all the form contents in that scrollView but my scrollView doesnt working ,It not scrolls down,My code is as below:
main.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="fill_parent"
android:orientation="vertical" >
<View
android:id="#+id/line"
android:layout_width="fill_parent"
android:layout_height="7dp"
android:layout_alignParentTop="true"
android:background="#4fc1e9" />
<TextView
android:id="#+id/title_reg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/line"
android:gravity="center"
android:padding="13dp"
android:text="#string/title_registration"
android:textColor="#cecece"
android:textSize="16dp"
android:textStyle="bold" />
<RelativeLayout
android:id="#+id/btn_qq_login"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/title_reg" >
<TextView
android:id="#+id/tv_qq_login"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#5d9cec"
android:gravity="center"
android:padding="12dp"
android:text="#string/qq_login"
android:textColor="#ffffff"
android:textSize="18dp"
android:textStyle="bold" />
</RelativeLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/btn_qq_login"
android:fillViewport="true" >
<RelativeLayout
android:id="#+id/rl_1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/txt_or"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:text="#string/or"
android:textColor="#cecece"
android:textSize="16dp"
android:textStyle="bold" />
<TextView
android:id="#+id/txt_reg_new_account"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_or"
android:autoLink="web"
android:gravity="center"
android:text="#string/reg_new_account"
android:textColor="#cecece"
android:textColorLink="#cecece"
android:textSize="16dp"
android:textStyle="bold" />
<TextView
android:id="#+id/txt_ur_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_reg_new_account"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
android:text="#string/reg_name"
android:textColor="#cecece"
android:textSize="14dp" />
<EditText
android:id="#+id/et_txt_ur_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_ur_name"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:background="#drawable/bg_editext"
android:hint="#string/hint_reg_name"
android:padding="8dp"
android:textColorHint="#cecece"
android:textSize="14dp" />
<TextView
android:id="#+id/txt_ur_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/et_txt_ur_name"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
android:text="#string/reg_email"
android:textColor="#cecece"
android:textSize="14dp" />
<EditText
android:id="#+id/et_txt_ur_email"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_ur_email"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:background="#drawable/bg_editext"
android:hint="#string/hint_reg_email"
android:padding="8dp"
android:textColorHint="#cecece"
android:textSize="14dp" />
<TextView
android:id="#+id/txt_ur_phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/et_txt_ur_email"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
android:text="#string/reg_phone_number"
android:textColor="#cecece"
android:textSize="14dp" />
<EditText
android:id="#+id/et_txt_ur_phone"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_ur_phone"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:background="#drawable/bg_editext"
android:hint="#string/hint_reg_phone_number"
android:padding="8dp"
android:textColorHint="#cecece"
android:textSize="14dp" />
<TextView
android:id="#+id/txt_ur_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/et_txt_ur_phone"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
android:text="#string/reg_pwd"
android:textColor="#cecece"
android:textSize="14dp" />
<EditText
android:id="#+id/et_txt_ur_password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_ur_password"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="15dp"
android:background="#drawable/bg_editext"
android:hint="#string/hint_reg_pwd"
android:padding="8dp"
android:textColorHint="#cecece"
android:textSize="14dp" />
</RelativeLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/reg_bottom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#f5f7f9"
android:paddingBottom="5dp" >
<Button
android:id="#+id/btn_register"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:background="#drawable/btn_register"
android:gravity="center"
android:text="#string/btn_reg"
android:textColor="#ffffff" />
<TextView
android:id="#+id/txt_already_member"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/btn_register"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:text="#string/txt_already_member"
android:textColor="#babfc3"
android:textSize="12dp" />
<TextView
android:id="#+id/txt_already_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/btn_register"
android:layout_centerHorizontal="true"
android:layout_marginLeft="3dp"
android:layout_marginTop="5dp"
android:layout_toRightOf="#+id/txt_already_member"
android:autoLink="web"
android:text="#string/txt_already_login"
android:textColor="#3a91ea"
android:textColorLink="#cecece"
android:textSize="12dp" />
</RelativeLayout>
<ImageView
android:id="#+id/iv_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_marginTop="47dp"
android:background="#drawable/qq" />
</RelativeLayout>
Please help me sort it out..Thank you
you have problem with ScrollView.you need to specify to the scroll view for scrolling.
just add below property in to ScrollView
android:layout_above="#+id/reg_bottom"
you need to bind your scroll view.
thanx.
i'm creating a custom list item in and android list view. it's very simple,but we can't align image view at right center
PLz help me how we can align image at right center
<?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="fill_parent" >
<ImageView
android:id="#+id/img"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:background="#drawable/star1" />
<TextView
android:id="#+id/txt_company"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:textColor="#25383C"
android:singleLine="true"
android:textStyle="bold"
android:textSize="16dp" />
<TextView
android:id="#+id/txt_position"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_company"
android:textColor="#25383C"
android:singleLine="true"
android:textSize="16dp" />
<TextView
android:id="#+id/txt_city"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_position"
android:textColor="#25383C"
android:textStyle="bold"
android:singleLine="true"
android:textSize="16dp" />
<TextView
android:id="#+id/txt_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_city"
android:textColor="#25383C"
android:textStyle="bold"
android:singleLine="true"
android:textSize="16dp" />
</RelativeLayout>
Please suggest me ,How we can align image view at right center
Thank you in advance
Try this..
Use android:layout_centerVertical="true" for the ImageView
<ImageView
android:id="#+id/img"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#drawable/star1" />
You can also 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" >
<LinearLayout
android:id="#+id/llTextOuter"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:padding="4dp" >
<TextView
android:id="#+id/txt_company"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="hello"
android:textColor="#25383C"
android:textSize="16dp"
android:textStyle="bold" />
<TextView
android:id="#+id/txt_position"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:singleLine="true"
android:text="hello"
android:textColor="#25383C"
android:textSize="16dp" />
<TextView
android:id="#+id/txt_city"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="hello"
android:textColor="#25383C"
android:textSize="16dp"
android:textStyle="bold" />
<TextView
android:id="#+id/txt_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="hello"
android:textColor="#25383C"
android:textSize="16dp"
android:textStyle="bold" />
</LinearLayout>
<ImageView
android:id="#+id/img"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:background="#drawable/star1" />
</LinearLayout>
Try this
<?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="fill_parent">
<ImageView
android:id="#+id/img"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#drawable/star1" />
<LinearLayout
android:id="#+id/llTextOuter"
android:layout_width="fill_parent"
android:layout_toLeftOf="#+id/img"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:orientation="vertical"
android:padding="4dp">
<TextView
android:id="#+id/txt_company"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:singleLine="true"
android:text="hello"
android:textColor="#25383C"
android:textSize="16dp"
android:textStyle="bold" />
<TextView
android:id="#+id/txt_position"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginTop="10dp"
android:singleLine="true"
android:text="hello"
android:textColor="#25383C"
android:textSize="16dp" />
<TextView
android:id="#+id/txt_city"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:singleLine="true"
android:text="hello"
android:textColor="#25383C"
android:textSize="16dp"
android:textStyle="bold" />
<TextView
android:id="#+id/txt_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:singleLine="true"
android:text="hello"
android:textColor="#25383C"
android:textSize="16dp"
android:textStyle="bold" />
</LinearLayout>
your imageview is aligned to right, if you want to center it vertically, you can use android:layout_centerVertical="true"
I have an ImageView (android:id="#+id/unreadmail) which i want to show on extreme left of ListItem as shown in image. But it is not aligning properly. Any idea if i am missing anything ?
<LinearLayout
android:id="#+id/Text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/emailsubject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center"
android:singleLine="true"
android:text="abcd"
android:textColor="#444444"
android:textSize="18sp" />
<TextView
android:id="#+id/emailcontent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/emailsubject"
android:layout_below="#id/emailsubject"
android:ellipsize="marquee"
android:gravity="center"
android:singleLine="true"
android:text="defg"
android:textColor="#444444"
android:textSize="14sp" />
</LinearLayout>
<ImageView
android:id="#+id/unreademail"
android:layout_width="2dip"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/emailsubject"
android:layout_centerVertical="true"
android:background="#8A6175"
android:visibility="invisible" />
<TextView
android:id="#+id/rcvdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:paddingRight="20dip"
android:textColor="#313132"
android:textSize="12sp" />
Use this:
<LinearLayout 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:orientation="vertical"
tools:context=".MainActivity"
tools:ignore="ObsoleteLayoutParam,ContentDescription,UselessLeaf,UselessParent" >
<LinearLayout
android:id="#+id/Text"
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal" >
<ImageView
android:id="#+id/unreademail"
android:layout_width="15dip"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#drawable/ic_launcher"
android:visibility="visible" />
<LinearLayout
android:id="#+id/Text"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_marginLeft="20dp"
android:orientation="vertical" >
<TextView
android:id="#+id/emailsubject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center"
android:singleLine="true"
android:text="abcd"
android:textColor="#444444"
android:textSize="18sp" />
<TextView
android:id="#+id/emailcontent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/emailsubject"
android:layout_below="#id/emailsubject"
android:ellipsize="marquee"
android:gravity="center"
android:singleLine="true"
android:text="defg"
android:textColor="#444444"
android:textSize="14sp" />
</LinearLayout>
<RelativeLayout
android:id="#+id/Text1"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:gravity="right"
android:layout_gravity="right"
android:orientation="horizontal" >
<TextView
android:id="#+id/rcvdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="35dp"
android:text="Date"
android:textColor="#000"
android:textSize="12sp" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
I think you should be using a relative layout at the top level (possibly not included in your code).
You cannot use 'to the left of' when the elements are at different levels in the heirarchy.
Thus I would start with your little icon left aligned to the parent and put the edit box (in the same relative view) 'to the right of' the icon.
This is the code sample for you there is no need to write the weight property if add the screenshot or the supported image how exactly you want then i can give you proper answer
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="#+id/Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/unreademail"
android:layout_marginLeft="10dip"
android:orientation="vertical">
<TextView
android:id="#+id/emailsubject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center"
android:singleLine="true"
android:text="abcd"
android:textColor="#444444"
android:textSize="18sp" />
<TextView
android:id="#+id/emailcontent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/emailsubject"
android:layout_below="#id/emailsubject"
android:ellipsize="marquee"
android:gravity="center"
android:singleLine="true"
android:text="defg"
android:textColor="#444444"
android:textSize="14sp" />
</LinearLayout>
<ImageView
android:id="#+id/unreademail"
android:layout_width="2dip"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:layout_marginBottom="5dip"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="#8A6175"
android:visibility="invisible" />
<TextView
android:id="#+id/rcvdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:paddingRight="20dip"
android:textColor="#313132"
android:textSize="12sp" />
</RelativeLayout>