Image left to TextView, Textview should be in center - android

I need to take a textview within Tablelayout with a image icon left to TextView. The TableLayout have width has fill_parent, so that whole area is clickable.
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="top"
android:drawablePadding="5dp"
android:drawableStart="#drawable/down_arrow"
android:gravity="start|center"
android:text="#string/hello_world" />
</TableLayout>
I tried to bring the Textview with image to center, but not able to do that.
Kindly help me to achieve the same.
Thanks
Vikash

try this :
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:drawablePadding="5dp"
android:drawableStart="#drawable/ic_launcher_0"
android:gravity="start|center"
android:text="#string/hello_world" />
</TableRow>
</TableLayout>

Use this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="32dp"
android:src="#drawable/app_icon" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/imageView1"
android:layout_marginBottom="24dp"
android:layout_marginLeft="20dp"
android:layout_toRightOf="#+id/imageView1"
android:text="TextView" />
</RelativeLayout>

Related

Android displaying linear layout in center to textview

Iam having a custom list view where in a row i have 3 text views and 3 images each below each textview
(Relative Layout)
TextView1 Textiew2 TextView3
opening---->(LinearLayout1) (LinearLayout2) (LinearLayout3)
ImageView1 ImageView2 ImageView3
closing---->(/LinearLayout1) (/LinearLayout2) (/LinearLayout3)
closing-->(/RelativeLayout)
Now the output comes like the imageview is not center totextview, i mean if you have your text and image in center and its centerhorizontal then how it looks like, i need same on right and left end too, text and image in right end should be centered in right side , and same for left also. Please suggest me what to do.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/textView1"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="49dp"
android:layout_marginTop="43dp"
android:gravity="center"
android:text="TextView" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:gravity="center"
android:layout_below="#+id/textView1"
android:layout_marginRight="47dp" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/book1" />
</LinearLayout>
</RelativeLayout>
In this above xml my textview is leftaligned and its text inside is centered, Now iam having one image below it which i want to align center of the above textview not parents center
Try this:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="0.33">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your title"
android:textStyle="bold" />
<ImageView
android:id="#+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="0.33">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your title"
android:textStyle="bold" />
<ImageView
android:id="#+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="0.34">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your title"
android:textStyle="bold" />
<ImageView
android:id="#+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
Try That:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="49dp"
android:layout_marginTop="43dp"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="TextView" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="#drawable/book1" />
</LinearLayout>

How to put a TEXTVIEW center on a IMAGEVIEW in Android Layout

I would like to know, how I can a put a text center on a image, here is the sample image,
I tried the below code, but its not working fine,
<LinearLayout
android:layout_width="100dip"
android:layout_height="fill_parent"
android:layout_marginRight="5dip"
android:gravity="center"
android:orientation="vertical" >
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/points"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:text="+2"
android:textColor="#fff"
android:textSize="16sp" />
<ImageView
android:id="#+id/btbt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/btbt" />
</TableRow>
</TableLayout>
</LinearLayout>
Please let me know a good solution.
you can use an imagebutton for this purpose
i will prefer using imagebutton
.. or
put this imageview in this order
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Relativelayout android:layout_width="wrap_content"
android:layout_height="match_parent" >
<TextView
android:id="#+id/points"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:text="+2"
android:textColor="#fff"
android:textSize="16sp" />
<ImageView
android:id="#+id/btbt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/btbt" />
</Relativelayout >
</TableRow>
You could try creating a textview with a background image. Something like:
<TextView
android:id="#+id/textview1"
xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="center"
android:textColor="#000000"
android:textStyle="bold"
android:text="Random Text"
android:background="#drawable/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

android layout textview between two button

I have comman header with two button and single textview.
textview is in center of the screen. button 1 is at the right side of the parent and button2 is at the left side of the parent.
now, I want to show text view in the center of the parent not in the center of the space between two buttons.
Text length in the textview can be any thing either it could be 3 words or it could be more than 10 word.
I dont want to overlap textview above the two buttons while length is more than 10 words.
and also I want textview in the center of the screen while there is only 3 words.
When I am using below code it is not showing textview in the center of the screen horizontally when there is only 3 to 4 words but below code also dont overlap while there is more than 10 words.
<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"
tools:context=".Webviewdemo" >
<ImageView
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="#drawable/backbtn" />
<ImageView
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#drawable/infobtn" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_toLeftOf="#+id/button2"
android:layout_toRightOf="#+id/button1"
android:gravity="center"
android:singleLine="true"
android:text="123"
android:textSize="22sp"/>
</RelativeLayout>
In same way When I am using below code it is showing textview in the center of the screen horizontally when there is only 3 to 4 words but below code overlap while there is more than 10 words.
<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"
tools:context=".Webviewdemo" >
<ImageView
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="#drawable/backbtn" />
<ImageView
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#drawable/infobtn" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:singleLine="true"
android:text="123"
android:textSize="22sp" />
</RelativeLayout>
So, My question is how can I achive above both thing with single code.
Textview should not overlap while there is more words.
Textview should be in center while there is less no of words.
I hope you all get my problem. if any query plz ask.
<LinearLayout
android:id="#+id/panelIconLeft1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_margin="5dp" >
<Button
android:id="#+id/btnHome1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LOCATION"
android:onClick="btnHomeClick" />
</LinearLayout>
<TextView
android:id="#+id/txtHeading1"
style="#style/heading_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_toLeftOf="#+id/panelIconRight1"
android:layout_toRightOf="#id/panelIconLeft1"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center"
android:singleLine="true"
android:text=""
android:textColor="#android:color/white" />
<LinearLayout
android:id="#+id/panelIconRight1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_margin="5dp" >
<Button
android:id="#+id/btnFeedback1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Post Ad"
android:onClick="btnFeedbackClick" />
</LinearLayout
The above code will help you
Use This Code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="left">
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="right" >
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</LinearLayout>
try this code
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/button2"
android:layout_toRightOf="#+id/button1"
android:gravity="center"
android:singleLine="true"
android:text="123"
android:textSize="22sp"/>
EDIT
remove this line
android:layout_centerInParent="true"
try this (without centerInParent)
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/button2"
android:layout_toRightOf="#+id/button1"
android:gravity="center"
android:singleLine="true"
android:text="123"
android:textSize="22sp"/>

how to align text vertically center in android

I have arabic text, therefore I set gravity to right in order to start text from right side. Text starts from right now. But another issue is text starts to render from the top of the page. But I need to vertically center the text.
Although I tried several variations I couldnt make it vertically center.
Here is the sample of my xml file.
<LinearLayout
android:id="#+id/linearLayout5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginBottom="23dp"
android:gravity="right"
android:padding="#dimen/padding_maintextview"
android:text="#string/text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20sp" />
</LinearLayout>
Problem is with above textview.
Here I have put whole xml file.
<?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:background="#drawable/page1background"
android:paddingRight="#dimen/padding_large" >
<TextView
android:id="#+id/textView1"
android:layout_width="196dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:paddingTop="#dimen/padding_Title_Top"
android:text="#string/text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20sp" />
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textView1"
android:gravity="center_horizontal"
android:orientation="vertical" >
<View
android:id="#+id/view1"
android:layout_width="fill_parent"
android:layout_height="5dp" />
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#id/linearLayout2"
android:layout_below="#id/linearLayout1"
android:layout_gravity="center"
android:padding="#dimen/padding_maintextview" >
<LinearLayout
android:id="#+id/linearLayout5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginBottom="23dp"
android:gravity="right"
android:padding="#dimen/padding_maintextview"
android:text="#string/text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20sp" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" >
<View
android:id="#+id/view2"
android:layout_width="fill_parent"
android:layout_height="100dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" >
<ImageButton
android:id="#+id/back_arrow"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginBottom="30dp"
android:layout_marginRight="45dp"
android:layout_weight=".5"
android:background="#drawable/backbut"
android:contentDescription="#string/Description"
android:onClick="onClickBtn"
android:src="#drawable/backarrowpress" />
<ImageButton
android:id="#+id/copyButton"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginLeft="45dp"
android:layout_weight=".5"
android:background="#drawable/copy"
android:contentDescription="#string/Description"
android:onClick="onClickBtn" />
</LinearLayout>
</RelativeLayout>
Can anybody show me where I have done the mistake? I think problem is clear. If not tell me in comments.
Herewith I have appended updated code after review your answers.
<?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:background="#drawable/page1background"
android:paddingRight="#dimen/padding_large" >
<TextView
android:id="#+id/textView1"
android:layout_width="196dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:paddingTop="#dimen/padding_Title_Top"
android:text="#string/text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20sp" />
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textView1"
android:gravity="center_horizontal"
android:orientation="vertical" >
<View
android:id="#+id/view1"
android:layout_width="fill_parent"
android:layout_height="5dp" />
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#id/linearLayout2"
android:layout_below="#id/linearLayout1"
android:layout_gravity="center"
android:layout_centerInParent="true"
android:padding="#dimen/padding_maintextview" >
<LinearLayout
android:id="#+id/linearLayout5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:layout_marginBottom="23dp"
android:gravity="center_vertical|right"
android:padding="#dimen/padding_maintextview"
android:text="#string/text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20sp" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" >
<View
android:id="#+id/view2"
android:layout_width="fill_parent"
android:layout_height="100dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" >
<ImageButton
android:id="#+id/back_arrow"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginBottom="30dp"
android:layout_marginRight="45dp"
android:layout_weight=".5"
android:background="#drawable/backbut"
android:contentDescription="#string/Description"
android:onClick="onClickBtn"
android:src="#drawable/backarrowpress" />
<ImageButton
android:id="#+id/copyButton"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginLeft="45dp"
android:layout_weight=".5"
android:background="#drawable/copy"
android:contentDescription="#string/Description"
android:onClick="onClickBtn" />
</LinearLayout>
</RelativeLayout>
But I am in same situation. No text is vertically centered
Your TextView Attributes need to be something like,
<TextView ...
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical|right" ../>
Now, Description why these need to be done,
android:layout_width="match_parent"
android:layout_height="match_parent"
Makes your TextView to match_parent or fill_parent if You don't want to be it like, match_parent you have to give some specified values to layout_height so it get space for vertical center gravity. android:layout_width="match_parent" necessary because it align your TextView in Right side so you can recognize respect to Parent Layout of TextView.
Now, its about android:gravity which makes the content of Your TextView alignment. android:layout_gravity makes alignment of TextView respected to its Parent Layout.
Update:
As below comment says use fill_parent instead of match_parent. (Problem in some device.)
The problem is the padding of the font on the textview. Just add to your textview:
android:includeFontPadding="false"
just use like this to make anything to center
android:layout_gravity="center"
android:gravity="center"
updated :
android:layout_gravity="center|right"
android:gravity="center|right"
Updated : Just remove MarginBottom from your textview.. Do like this.. for your textView
<LinearLayout
android:id="#+id/linearLayout5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center" >
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center|right"
android:text="hello"
android:textSize="20dp" />
</LinearLayout>
Try to put android:gravity="center_vertical|right" inside parent LinearLayout else as you are inside RelativeLayout you can put android:layout_centerInParent="true" inside your scrollView.
In relative layout you need specify textview height:
android:layout_height="100dp"
Or specify lines attribute:
android:lines="3"

Fit two textView in LinearLayout next to an ImageView

I have this layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="#style/fill_parent"
android:background="#color/white"
android:padding="2dip">
<ImageView
android:id="#+id/img_album"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginRight="6dip"
android:layout_centerVertical="true"
android:padding="5dp"
/>
<LinearLayout
style="#style/fill_parent"
android:orientation="horizontal"
android:layout_toRightOf="#id/img_album"
android:layout_centerVertical="true">
<TextView
android:id="#+id/album_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="#color/black"
android:layout_marginRight="10dp"
/>
<TextView
android:id="#+id/picts_number"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#color/black"
/>
</LinearLayout>
</RelativeLayout>
Which gives me this image:
I dont know why I dont get the title of the album and next the number of picts.
Well, I did something using layout_weight property as:
<TextView
android:id="#+id/album_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="#color/black"
android:layout_marginRight="10dp"
android:layout_weight="1"
/>
<TextView
android:id="#+id/picts_number"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:layout_weight="1" />
And I dont really know why, I get now the number, next to the title, as
Could someone tell me:
Why I dont get the number in the 1st scenario, but I do in the 2nd.
How to expand the text all the width of the Linearyout, so the
second Text "Smartphones..." doesnt get stretch, but fits its
parent.
Thanks!
Using the width = 0dip and weigth = 1. I did it!
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="#style/fill_parent"
android:background="#color/white"
android:padding="2dip">
<ImageView
android:id="#+id/img_album"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginRight="6dip"
android:layout_centerVertical="true"
android:padding="5dp"
/>
<LinearLayout
style="#style/fill_parent"
android:orientation="horizontal"
android:layout_toRightOf="#id/img_album"
android:layout_centerVertical="true"
android:id="#+id/album_details">
<TextView
android:id="#+id/album_title"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="#color/black"
android:layout_marginRight="30dp"
android:textSize="17sp"
android:layout_weight="1"
/>
<TextView
android:id="#+id/picts_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:layout_weight="0"
android:textSize="17sp"
android:layout_gravity="right"
android:layout_marginRight="10dp"
/>
</LinearLayout>
</RelativeLayout>
Try to make it with a FrameLayout rather than a RelativeLayout. It's really easier to build your layout with this. Something like this, but with size and style adaptation :
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:padding="2dp">
<ImageView
android:id="#+id/img_album"
android:layout_width="50dp"
android:layout_height="fill_parent"
android:layout_marginRight="6dp"
android:cropToPadding="true"
android:layout_centerVertical="true"
android:padding="5dp"
/>
<TextView
android:id="#+id/album_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_gravity="center"
android:singleLine="true"
android:textColor="#color/black"
android:layout_marginRight="50dp"
/>
<TextView
android:id="#+id/picts_number"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:textColor="#color/black"
/>
</FrameLayout>

Categories

Resources