I am trying to add three text views as follows, but I could not able to achieve it. I want A to be on the left side, and the other two texviews to be right side.
Here is what I get:
Here is my current implementation
<RelativeLayout
android:id="#+id/mainlayout"
android:layout_width="match_parent"
android:layout_height="40dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:background="#363636">
<TextView
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="A"
android:textColor="#android:color/white"
android:paddingTop="3dp"
android:paddingBottom="3dp"
android:textSize="16sp"
android:fontFamily="sans-serif-medium" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:id="#+id/innerLayout">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:text="B "
android:textSize="16sp"
android:textColor="#android:color/white"
android:paddingRight="8dp" />
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:text="C "
android:textSize="16sp"
android:textColor="#android:color/white"
android:paddingTop="3dp"
android:paddingBottom="3dp"
android:paddingLeft="8dp"
android:paddingRight="8dp" />
</RelativeLayout>
</RelativeLayout>
use this:
<RelativeLayout 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"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:id="#+id/A"
android:text="aaaaaaa"
android:padding="8dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:id="#+id/C"
android:text="ccccccc"
android:padding="8dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/C"
android:id="#+id/B"
android:text="bbbbbbb"
android:padding="8dp"/>
</RelativeLayout>
Change the xml like this ,
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mainlayout"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#363636"
android:paddingLeft="20dp"
android:paddingRight="20dp">
<TextView android:background="#458765"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:fontFamily="sans-serif-medium"
android:paddingBottom="3dp"
android:paddingTop="3dp"
android:text="A"
android:textColor="#android:color/white"
android:textSize="16sp" />
<RelativeLayout
android:id="#+id/innerLayout"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignParentRight="true">
<TextView android:background="#458765"
android:id="#+id/b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="B"
android:textColor="#android:color/white"
android:textSize="16sp" />
<TextView android:layout_marginLeft="5dp" android:background="#458765"
android:layout_toRightOf="#id/b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="C"
android:textColor="#android:color/white"
android:textSize="16sp" />
</RelativeLayout>
</RelativeLayout>
Related
My layout results in the error "ScrollView can host only one direct child" when using RelativeLayout.
I want to add a scroll view after a toolbar. Everything inside the ScrollView should be scrollable vertically, but when I try this code, it results in the aforementioned error "ScrollView can host only one direct child with relativelayout".
The Layout.xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
//Scroll view starts here
<include
android:id="#+id/toolbar"
layout="#layout/view_toolbar" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/grey_868686">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="Most Download"
android:layout_centerVertical="true"
android:textSize="14sp"
android:textColor="#color/white"
android:paddingRight="8dp"
android:paddingLeft="8dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="More"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:textSize="14sp"
android:textColor="#color/white"
android:paddingRight="8dp"
android:paddingLeft="8dp"
android:onClick="onOtherVideo"/>
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/rv_video_terbaru"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/grey_868686">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="Funny Video"
android:layout_centerVertical="true"
android:textSize="14sp"
android:textColor="#color/white"
android:paddingRight="8dp"
android:paddingLeft="8dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="More"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:textSize="14sp"
android:textColor="#color/white"
android:paddingRight="8dp"
android:paddingLeft="8dp"
android:onClick="onOtherVideoFunny"/>
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/rv_funny_video"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/grey_868686">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="Religy Video"
android:layout_centerVertical="true"
android:textSize="14sp"
android:textColor="#color/white"
android:paddingRight="8dp"
android:paddingLeft="8dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="More"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:textSize="14sp"
android:textColor="#color/white"
android:paddingRight="8dp"
android:paddingLeft="8dp"
android:onClick="onOtherReligyVideo"/>
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/rv_religi_video"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/grey_868686">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="Others Video"
android:layout_centerVertical="true"
android:textSize="14sp"
android:textColor="#color/white"
android:paddingRight="8dp"
android:paddingLeft="8dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="More"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:textSize="14sp"
android:textColor="#color/white"
android:paddingRight="8dp"
android:paddingLeft="8dp"
android:onClick="onOtherMoreVideo"/>
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/rv_others_video"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</ScrollView>
</LinearLayout>
The Answer given by Md.ibrahim khalil is absolutely right,
Try by replacing your layout with 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="match_parent"
android:orientation="vertical">
//Scroll view starts here
<include
android:id="#+id/toolbar"
layout="#layout/view_toolbar" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/grey_868686">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:gravity="center_vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="Most Download"
android:textColor="#color/white"
android:textSize="14sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:gravity="center_vertical"
android:onClick="onOtherVideo"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="More"
android:textColor="#color/white"
android:textSize="14sp" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/rv_video_terbaru"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/grey_868686">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:gravity="center_vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="Funny Video"
android:textColor="#color/white"
android:textSize="14sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:gravity="center_vertical"
android:onClick="onOtherVideoFunny"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="More"
android:textColor="#color/white"
android:textSize="14sp" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/rv_funny_video"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/grey_868686">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:gravity="center_vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="Religy Video"
android:textColor="#color/white"
android:textSize="14sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:gravity="center_vertical"
android:onClick="onOtherReligyVideo"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="More"
android:textColor="#color/white"
android:textSize="14sp" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/rv_religi_video"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/grey_868686">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:gravity="center_vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="Others Video"
android:textColor="#color/white"
android:textSize="14sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:gravity="center_vertical"
android:onClick="onOtherMoreVideo"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="More"
android:textColor="#color/white"
android:textSize="14sp" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/rv_others_video"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
</LinearLayout>
take a relative layout or linear layout then put all view into it and then wrap this relative layout with scroll view
your problem will be solved.
Good day guys. I seriously need someone help to adjust my xml layout.
The above image shows the ListView, where it supposes to look like :
Image on the left, text on the right
Claims Type : Project
Amount : 100
Description : Trainning
xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="start"
android:background="#android:color/white"
android:padding="12dp">
<ImageView
android:id="#+id/image"
android:layout_width="80dp"
android:layout_height="70dp"
android:layout_centerVertical="true"
android:layout_gravity="left"/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/image"
android:layout_marginRight="4dp"
android:layout_centerVertical="true"
android:paddingLeft="6dp"
android:orientation="vertical">
<TextView
android:id="#+id/Claimtype"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:text="Claims Type : "
android:maxLines="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/type"
android:layout_toRightOf="#+id/Claimtype"/>
<TextView
android:id="#+id/Amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textColor="#android:color/secondary_text_dark_nodisable"
android:text="Amount : "
android:maxLines="1"
android:ellipsize="end"
android:layout_below="#+id/Claimtype" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/amount"
android:layout_toRightOf="#+id/Amount"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textColor="#android:color/secondary_text_dark_nodisable"
android:text="Description : "
android:maxLines="1"
android:layout_below="#+id/Amount" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/description"
android:layout_toRightOf="#+id/Description"/>
</RelativeLayout>
</RelativeLayout>
Thanks a lot ..
Simply you just need a LinearLayout:
<?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"
android:weightSum="1">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.6"
android:id="#+id/imageView"/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.4"
android:id="#+id/textView"/>
</LinearLayout>
And create String like:
Claims Type : "yourType" + "\n"
Amount : 100 + "\n"
Description : Trainning + "\n"
to set for your TextView
You can try that, i do it, fast so it's not really beautiful but it's what you want (i think). Try to not put solid value.
<?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"
android:orientation="horizontal"
android:gravity="start"
android:background="#android:color/white"
android:padding="12dp">
<ImageView
android:id="#+id/image"
android:layout_width="80dp"
android:layout_height="70dp"
android:layout_centerVertical="true"
android:layout_gravity="left"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/image"
android:layout_centerVertical="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/Claimtype"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:text="Claims Type : "
android:maxLines="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/type"
android:layout_toRightOf="#+id/Claimtype"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/image"
android:layout_centerVertical="true"
android:orientation="horizontal">
<TextView
android:id="#+id/Amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textColor="#android:color/secondary_text_dark_nodisable"
android:text="Amount : "
android:maxLines="1"
android:ellipsize="end"
android:layout_below="#+id/Claimtype" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/amount"
android:layout_toRightOf="#+id/Amount"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/image"
android:layout_centerVertical="true"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textColor="#android:color/secondary_text_dark_nodisable"
android:text="Description : "
android:maxLines="1"
android:layout_below="#+id/Amount" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/description"
android:layout_toRightOf="#+id/Description"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
For performance purposes, do not embed RelativeLayouts one into another. Since you only have two child in the parent RelativeLayout, you can use a LinearLayout instead.
Now regarding your issue :
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/amount"
android:layout_toRightOf="#+id/Amount"/>
layout_toRightOf means the TextView will be place at the right of the indicated View, only horizontally. You need to add a layout_below attribute also.
try this, I have done it into my workspace.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mytextview="http://schemas.android.com/apk/res/com.bne"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/rlMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp" >
<ImageView
android:id="#+id/imgCover"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="#drawable/ic_launcher" />
<RelativeLayout
android:id="#+id/rlHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="2dp"
android:layout_toLeftOf="#+id/imgArrow"
android:layout_toRightOf="#+id/imgCover" >
<TextView
android:id="#+id/txtCoverHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#android:color/black"
android:textSize="14sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/rlCT"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/imgCover" >
<TextView
android:id="#+id/txtCT"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/txtDateTime"
android:gravity="center"
android:text="Claims Type :"
android:textColor="#android:color/black"
android:textSize="10sp" />
<TextView
android:id="#+id/txtOutCT"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/txtCT"
android:gravity="center"
android:text="Project"
android:textColor="#android:color/black"
android:textSize="10sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/rlAmount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/rlCT"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/imgCover" >
<TextView
android:id="#+id/txtAmount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/txtDateTime"
android:gravity="center"
android:text="Amount :"
android:textColor="#android:color/black"
android:textSize="10sp" />
<TextView
android:id="#+id/txtOutAmount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/txtAmount"
android:gravity="center"
android:text="100"
android:textColor="#android:color/black"
android:textSize="10sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/rlTraining"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/rlAmount"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/imgCover" >
<TextView
android:id="#+id/txtTraining"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/txtDateTime"
android:gravity="center"
android:text="Description :"
android:textColor="#android:color/black"
android:textSize="10sp" />
<TextView
android:id="#+id/txtOutTraining"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/txtTraining"
android:gravity="center"
android:text="Trainning"
android:textColor="#android:color/black"
android:textSize="10sp" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
Use this and let me know if some issue
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="start"
android:background="#android:color/white"
android:padding="12dp">
<ImageView
android:id="#+id/image"
android:layout_width="80dp"
android:layout_height="70dp"
android:layout_centerVertical="true"
android:layout_gravity="left"/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/image"
android:layout_centerVertical="true"
android:paddingLeft="6dp"
android:orientation="vertical"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">
<LinearLayout
android:id="#+id/ll1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/Claimtype"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:text="Claims Type : "
android:singleLine="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/type"
android:text="dsjfhjh"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/ll2"
android:layout_below="#+id/ll1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/Amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textColor="#android:color/secondary_text_dark_nodisable"
android:text="Amount : "
android:maxLines="1"
android:ellipsize="end" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/amount"
android:text="dsjfhjsdkh" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll3"
android:layout_below="#+id/ll2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textColor="#android:color/secondary_text_dark_nodisable"
android:text="Description : "
android:maxLines="1"
android:layout_below="#+id/Amount" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/description"
android:text="jksdhfj"
android:layout_toRightOf="#+id/Description"/>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
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 a problem, I have a long layout so I need it will be scrollable. But I need two listview in it. I have made using linearlayout and in forcycle I add a items in it. But I have lost all functions what listview offers and I want to use them.
Do anybody knows, how looks like "events" view in facebook app? It looks like there are a lot of listviews (birthdays, events, ...) and whole view is scrollable. I need something like this.
Thank you for ansver. :)
EDIT: There is my xml (There are two LinearLayouts: #+id/passengersList and #+id/discussionList and I want use ListViews instead):
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/travelDetailScroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#f8ffe1"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:paddingRight="5dp"
android:paddingLeft="5dp">
<TextView
android:id="#+id/travelId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
<RelativeLayout
android:id="#+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/waypoints"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:textColor="#333333"
android:textSize="16sp" />
<ImageView
android:id="#+id/travelMap"
android:layout_width="70dp"
android:layout_height="70dp"
android:paddingLeft="0dp"
android:paddingTop="0dp"
android:paddingRight="8dp"
android:layout_below="#+id/waypoints"
android:contentDescription="#string/travel_detail" />
<TextView
android:id="#+id/driver"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/waypoints"
android:layout_toRightOf="#+id/travelMap"
android:textColor="#333333"
android:textSize="14sp" />
<TextView
android:id="#+id/car"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/driver"
android:layout_toRightOf="#+id/travelMap"
android:paddingBottom="10dp"
android:textColor="#333333"
android:textSize="14sp" />
<TextView
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/waypoints"
android:textColor="#aaaaaa"
android:layout_alignParentRight="true"
android:textSize="14sp" />
<TextView
android:id="#+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/date"
android:layout_alignParentRight="true"
android:textColor="#aaaaaa"
android:textSize="14sp" />
<ImageView
android:id="#+id/icon_price"
android:layout_below="#+id/car"
android:layout_toRightOf="#+id/travelMap"
android:layout_width="20dp"
android:layout_height="20dp"
android:paddingLeft="0dp"
android:paddingTop="0dp"
android:paddingRight="6dp"
android:contentDescription="#string/travel_price" />
<TextView
android:id="#+id/price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/car"
android:layout_toRightOf="#+id/icon_price"
android:paddingRight="40dp"
android:textColor="#333333"
android:textSize="14sp" />
<ImageView
android:id="#+id/icon_seats"
android:layout_below="#+id/car"
android:layout_toRightOf="#+id/price"
android:layout_gravity="center|center_vertical"
android:layout_width="20dp"
android:layout_height="20dp"
android:paddingLeft="0dp"
android:paddingTop="0dp"
android:paddingRight="6dp"
android:contentDescription="#string/travel_seats" />
<TextView
android:id="#+id/seats"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/car"
android:layout_toRightOf="#+id/icon_seats"
android:layout_gravity="center|center_vertical"
android:paddingBottom="10dp"
android:textColor="#333333"
android:textSize="14sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/buttons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header"
android:layout_centerHorizontal="true" >
<RelativeLayout
android:id="#+id/buttonsLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="#+id/btn_travel_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/travel_login" />
<Button
android:id="#+id/btn_travel_logout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/travel_logout"
android:visibility="gone" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/buttonsRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="8dp"
android:layout_toRightOf="#+id/buttonsLeft" >
<Button
android:id="#+id/btn_travel_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/travel_edit"
android:visibility="gone" />
<Button
android:id="#+id/btn_travel_watch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/travel_watch"
android:visibility="gone" />
<Button
android:id="#+id/btn_travel_unwatch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/travel_unwatch"
android:visibility="gone" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/buttons"
android:paddingTop="10dp">
<TextView
android:id="#+id/driverTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|center_vertical"
android:paddingBottom="2dp"
android:textColor="#333333"
android:textSize="14sp"
android:text="#string/driver_title" />
<RelativeLayout
android:id="#+id/driverInfo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/driverTitle"
android:background="#f8ffe1">
<ImageView
android:id="#+id/driverPhoto"
android:layout_width="65dp"
android:layout_height="65dp"
android:paddingRight="8dp"
android:paddingLeft="0dp"
android:paddingTop="0dp" />
<TextView
android:id="#+id/driverName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:layout_toRightOf="#+id/driverPhoto"
android:textColor="#333333"
android:textSize="16sp" />
<TextView
android:id="#+id/driverEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/driverName"
android:layout_toRightOf="#+id/driverPhoto"
android:textColor="#999999"
android:textSize="14sp" />
<TextView
android:id="#+id/driverPhone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/driverEmail"
android:layout_toRightOf="#+id/driverPhoto"
android:paddingBottom="10dp"
android:textColor="#333333"
android:textSize="14sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/passengersInfo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/driverInfo"
android:paddingTop="10dp">
<TextView
android:id="#+id/passengersTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|center_vertical"
android:paddingTop="7dp"
android:paddingBottom="2dp"
android:textColor="#333333"
android:textSize="14sp"
android:text="#string/passengers_title" />
<TextView
android:id="#+id/noPassengers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="#+id/passengersTitle"
android:textColor="#333333"
android:textSize="14sp"
android:text="#string/no_passengers"
android:visibility="gone" />
<LinearLayout
android:id="#+id/passengersList"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_below="#+id/passengersTitle"
android:orientation="vertical" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/discussion"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/passengersInfo"
android:paddingTop="10dp">
<TextView
android:id="#+id/discussionTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="2dp"
android:textColor="#333333"
android:textSize="14sp"
android:text="#string/discussion_title" />
<LinearLayout
android:id="#+id/discussionList"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_below="#+id/discussionTitle"
android:orientation="vertical" />
<TextView
android:id="#+id/addMessageLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="7dp"
android:paddingBottom="2dp"
android:textColor="#8ec83e"
android:textSize="14sp"
android:layout_below="#+id/discussionList"
android:layout_centerHorizontal="true"
android:text="#string/add_message" />
<LinearLayout android:id="#+id/newMessageLayout"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_below="#+id/addMessageLink"
android:orientation="horizontal"
android:paddingTop="7dp"
android:paddingBottom="2dp"
android:visibility="gone">
<EditText
android:id="#+id/newMessage"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="#333333"
android:textSize="14sp"
android:hint="#string/new_message"
android:layout_weight="3" />
<Button
android:id="#+id/addMessage"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="#333333"
android:textSize="14sp"
android:hint="#string/send_message"
android:layout_gravity="right"
android:layout_weight="1" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/waypointsDetail"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/discussion"
android:paddingTop="10dp">
<TextView
android:id="#+id/waypointsTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="2dp"
android:textColor="#333333"
android:textSize="14sp"
android:text="#string/waypoints_title" />
<LinearLayout android:id="#+id/waypointsList"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_below="#+id/waypointsTitle"
android:orientation="vertical" />
<TextView
android:id="#+id/waypointsSummary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="2dp"
android:textColor="#333333"
android:textSize="14sp"
android:layout_below="#+id/waypointsList" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
I am using an activity with style of android:theme="#android:style/Theme.Dialog" .The activity is shown as dialog but the problem is to reduce the height of the dialog to specified level..
Please give me a solution??????
This is my activity dialog XML code
<?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:background="#drawable/bg"
android:orientation="vertical"
style="#style/MyActionsDialogTheme">
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#drawable/custom_title"
android:gravity="center_vertical" >
<RelativeLayout
android:id="#+id/relativeLayout2"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:gravity="center_vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:gravity="center_vertical"
android:text="Quick Actions"
android:textColor="#ffffff"
android:textSize="18dp"
android:textStyle="bold|italic"
android:typeface="serif" />
</RelativeLayout>
</RelativeLayout>
<TextView
android:id="#+id/tv_edit"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:text="Edit Reminder"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000"
android:textStyle="bold|italic"
android:typeface="serif" />
<TextView
android:id="#+id/tv_delete"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="Delete Reminder"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000"
android:textStyle="bold|italic"
android:typeface="serif" />
<Button
android:id="#+id/btn_cancel"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/custom_button"
android:text="Cancel"
android:textColor="#ffffff"
android:textStyle="bold|italic"
android:typeface="serif" />
</LinearLayout>
Try this.. give dialog main layout hight as wrap_content
if you give match_parent means it'll fill the parent layout full so give wrap_content
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#drawable/custom_title"
android:gravity="center_vertical" >
<RelativeLayout
android:id="#+id/relativeLayout2"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:gravity="center_vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:gravity="center_vertical"
android:text="Quick Actions"
android:textColor="#ffffff"
android:textSize="18dp"
android:textStyle="bold|italic"
android:typeface="serif" />
</RelativeLayout>
</RelativeLayout>
<TextView
android:id="#+id/tv_edit"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:text="Edit Reminder"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000"
android:textStyle="bold|italic"
android:typeface="serif" />
<TextView
android:id="#+id/tv_delete"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="Delete Reminder"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000"
android:textStyle="bold|italic"
android:typeface="serif" />
<Button
android:id="#+id/btn_cancel"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/custom_button"
android:text="Cancel"
android:textColor="#ffffff"
android:textStyle="bold|italic"
android:typeface="serif" />
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"
android:background="#drawable/bg"
android:orientation="vertical"
style="#style/MyActionsDialogTheme">
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#drawable/custom_title"
android:gravity="center_vertical" >
<RelativeLayout
android:id="#+id/relativeLayout2"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:gravity="center_vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:gravity="center_vertical"
android:text="Quick Actions"
android:textColor="#ffffff"
android:textSize="18dp"
android:textStyle="bold|italic"
android:typeface="serif" />
</RelativeLayout>
</RelativeLayout>
<TextView
android:id="#+id/tv_edit"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:text="Edit Reminder"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000"
android:textStyle="bold|italic"
android:typeface="serif" />
<TextView
android:id="#+id/tv_delete"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="Delete Reminder"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000"
android:textStyle="bold|italic"
android:typeface="serif" />
<Button
android:id="#+id/btn_cancel"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/custom_button"
android:text="Cancel"
android:textColor="#ffffff"
android:textStyle="bold|italic"
android:typeface="serif" />
</LinearLayout>
use wrap Content in place of matchparent in LinearLayout
Just reduce the background image , then it's work