Unable to set text view at the bottom of other text view - android-layout

I have an ImaveView images and corresponding to each image there is TextView img_name and img_source, I want to align them like 1st image should be placed and at right of image image_name should be displayed and below img_name, img_source should be display.
I have tried with below layout code but couldn't work as expected
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="start"
>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/imageview_cover_art"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:gravity="center_horizontal"/>
<ImageView
android:id="#+id/imageview_favorite"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="#drawable/star_disabled"
android:layout_gravity="bottom|right"/>
</FrameLayout>
<TextView
android:id="#+id/textview_book_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
tools:text="Are You My Mother"
android:textStyle="bold"
android:paddingTop="4dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:gravity="center_horizontal"/>
<TextView
android:id="#+id/textview_book_author"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
tools:text="Dr. Seuss"
android:gravity="center_horizontal"
android:orientation="vertical"/>
</LinearLayout>
It is displaying like
Image > TextView > TextView
but i require like:
Image > TextView
TextView
Also if first TetView is bigger then need to break in another line
Please help.

Just add the two textview into another linearview with vertical orientation :-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="start"
>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/imageview_cover_art"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:gravity="center_horizontal"/>
<ImageView
android:id="#+id/imageview_favorite"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="#drawable/star_disabled"
android:layout_gravity="bottom|right"/>
</FrameLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/textview_book_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
tools:text="Are You My Mother"
android:textStyle="bold"
android:paddingTop="4dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:gravity="center_horizontal"/>
<TextView
android:id="#+id/textview_book_author"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
tools:text="Dr. Seuss"
android:gravity="center_horizontal"
android:orientation="vertical"/>
</LinearLayout>
</LinearLayout>

Simply place views in Linear Layout after that add android:orientation="vertical"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/textview_book_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
tools:text="Are You My Mother"
android:textStyle="bold"
android:paddingTop="4dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
/>
<TextView
android:id="#+id/textview_book_author"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
tools:text="Dr. Seuss" />
</LinearLayout>

Related

in a relativelayout how to position a textview in the middle of another textview above

I'm trying to achieve the following output. I have 2 TextView centrally split and below they have each a substring centered respectively to their parent strings:
where suba and subb would be centered with their parent string.
In my XML I have hardcoded the value but I'd like to use a method which works whatever the screen size.
How could I do that?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/st_mid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:visibility="invisible"/>
<TextView
android:id="#+id/texta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/st_mid"
android:text="This is text A"
android:gravity="center"
android:layout_marginRight="40dp"
android:layout_marginTop="20dp"/>
<TextView
android:id="#+id/textaa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/texta"
android:layout_marginTop="15dp"
android:gravity="center"
android:text="suba"
android:layout_marginLeft="90dp"/>
<TextView
android:id="#+id/textb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/st_mid"
android:text="This is text B"
android:gravity="center"
android:layout_marginLeft="40dp"
android:layout_marginTop="20dp"/>
<TextView
android:id="#+id/textbb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textb"
android:layout_marginTop="15dp"
android:gravity="center"
android:text="subb"
android:layout_marginLeft="260dp"/>
</RelativeLayout>
sorry, too early in the morning...
I found a solution:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:id="#+id/st_mid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:visibility="invisible"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_toLeftOf="#id/st_mid"
>
<TextView
android:id="#+id/texta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is text A"
android:gravity="center"
android:layout_marginTop="20dp"
android:layout_centerHorizontal="true"
/>
<TextView
android:id="#+id/textaa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/texta"
android:layout_marginTop="15dp"
android:gravity="center"
android:text="suba"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_toRightOf="#id/st_mid"
>
<TextView
android:id="#+id/textb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is text B"
android:gravity="center"
android:layout_marginTop="20dp"
android:layout_centerHorizontal="true"
/>
<TextView
android:id="#+id/textbb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textb"
android:layout_marginTop="15dp"
android:gravity="center"
android:text="subb"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
</RelativeLayout>

How to design a layout similar to twitter's reply to a tweet android

On my app I when a user clicks on an item on the listview on the postmessageActivtiy it takes them to commentActivity , so I have been trying to design a layout that is similar to twitter ‘s reply to a tweet activity .On the comment side I have textviews that displays the postmessage and the user name of the user who posted it , below that I have a listView that is used to display the comments , below the listview I have a textEdit and a Postbutton aligned to the right of the text edit. The problem I am facing is that the layout doesn’t look right ,the listviews that displays the message and the username remain still on the same position whle the listview below scrolls up and down.How do I make the whole thing scroll up and down together?
<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="com.example.machimanapc.howzit.CommentActivity">
<RelativeLayout
android:id="#+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="#color/colorPrimary"
android:paddingTop="5dp"
android:paddingBottom="5dp">
<ImageButton
android:id="#+id/imgBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_left_white"
android:background="?android:selectableItemBackground"
android:layout_centerInParent="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/reply"
android:textColor="#color/textColorPrimary"
android:layout_centerInParent="true"
android:textSize="25sp"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:layout_centerVertical="true"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/content"
android:layout_marginTop="5dp"
android:layout_below="#+id/header">
<TextView
android:id="#+id/txtUsername_view_Respond"
android:textColor="#color/colorPrimaryDark"
android:textStyle="bold"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:textSize="6pt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
android:id="#+id/stuff"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="#+id/txtUsername_view_Respond"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:gravity="end">
<TextView
android:id="#+id/txtContent_view_Respond"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:textSize="6pt"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"
android:layout_gravity="end">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:src="#drawable/ic_action_up"
android:background="?android:selectableItemBackground"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#color/colorPrimary"
android:textStyle="bold" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_down"
android:background="?android:selectableItemBackground"
/>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/stuff">
<TextView
android:id="#+id/txtTimestamp_Reply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textColor="#color/Timestamp"
android:textSize="#dimen/feed_item_timestamp"/>
</RelativeLayout>
</RelativeLayout>
<ListView
android:id="#+id/posts_list_view"
android:layout_below="#+id/content"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="5dp"
/>
<RelativeLayout
android:id="#+id/footer"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/textColorPrimary"
android:layout_alignParentBottom="true">
<EditText
android:id="#+id/txtEdit_Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:hint="#string/prompt_reply"
android:layout_marginRight="5dp"
android:layout_marginEnd="5dp"
android:layout_marginTop="13dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="#+id/txtCharacter_count"
android:layout_toStartOf="#+id/txtCharacter_count"
android:inputType="textMultiLine"
android:singleLine="true"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/btnPost"
android:layout_marginRight="5dp"
android:layout_marginEnd="5dp"
android:layout_centerInParent="true"
android:text="#string/prompt_post"
android:background="#drawable/newrounded"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"/>
<TextView
android:id="#+id/txtCharacter_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/btnPost"
android:layout_toStartOf="#+id/btnPost"
android:layout_marginBottom="#dimen/activity_vertical_margin"
android:text="#string/character_count_placeholder"
android:layout_marginRight="5dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:gravity="center"
android:layout_marginTop="25dp"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"/>
</RelativeLayout>

keyboard overlap custom edittext

Greetings to all. What time I struggle with the problem. By clicking
on the EditText my keyboard covers half EditText. Tried to put in
Manifest adjustSpan - keyboard covers half EditTekst and adjustResize
- displays the top panel also RelativeLayout. Help solve the problem.
main activity layout
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layout_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/color_background_1">
<android.support.v4.widget.DrawerLayout
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/linear_bottom_panel" >
<FrameLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#5c4768" >
</FrameLayout>
<ListView
android:id="#+id/right_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="#android:color/darker_gray"
android:dividerHeight="0.1dp"/>
<ListView
android:id="#+id/new_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="end"
android:choiceMode="singleChoice"
android:divider="#android:color/darker_gray"
android:background="#5c4768"
android:dividerHeight="0.1dp"/>
</android.support.v4.widget.DrawerLayout>
<LinearLayout
android:id="#+id/linear_bottom_panel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#color/color_bottom_panel"
android:orientation="horizontal" >
<ImageView
android:id="#+id/image_main_news"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:src="#drawable/ic_main_news_selector" />
<ImageView
android:id="#+id/image_main_chat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:src="#drawable/ic_main_chat_selector" />
<ImageView
android:id="#+id/image_main_add_mp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:src="#drawable/ic_main_add_mp_selector" />
<ImageView
android:id="#+id/image_main_map"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center"
android:src="#drawable/ic_main_map_selector" />
<ImageView
android:id="#+id/image_main_user"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:src="#drawable/ic_main_user_selector" />
</LinearLayout>
<ProgressBar
android:id="#+id/progress_load"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="invisible"
android:indeterminateDrawable="#drawable/load_progress" />
</RelativeLayout>
this fragment layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/color_background_1" >
<include
android:id="#+id/discus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
layout="#layout/layout_discus_view"
/>
<ListView
android:id="#+id/list_chat"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/discus"
android:layout_above="#+id/add_message"
android:listSelector="#drawable/listview_item_selector"
>
</ListView>
<include
android:id="#+id/add_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
layout="#layout/layout_add_new_message"
/>
</RelativeLayout>
where adjustSpan layout #+id/add_message keyboard overlap

Scroll view of center aligned linear layout is wrapping top content in small resolution devices and landscape mode

Scroll view of center aligned linear layout is wrapping top content in small resolution devices as well as landscape mode too.
but when i removed the center_vertical in linear lay out it is working fine, but i want that linear layout to be in center_vertical only.
Below is my code:!
<ScrollView
android:id="#+id/bodyscrollview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fillViewport="true" >
<LinearLayout
style="#style/app_update_alert_bg"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:layout_marginBottom="5dp"
android:orientation="vertical" >
<TextView
style="#style/app_update_alert_bg_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/updateinfo1" />
<TextView
style="#style/app_update_alert_bg_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/updateinfo2" />
<ImageView
style="#style/margin5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#drawable/switching_image_border"
android:src="#drawable/switching_image_sb" />
<ImageView
style="#style/margin5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#drawable/switching_image_border"
android:src="#drawable/switching_image_ucc" />
<CheckBox
android:id="#+id/chckbox_dontshow_again"
style="#style/margin5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="#drawable/custom_checkbox"
android:text="#string/updateinfo_dontshow" />
<Button
android:id="#+id/btn_updatealert_confirmation"
style="#style/buttonStyle.signInButton"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="5dp"
android:text="OK" />
</LinearLayout>
</ScrollView>
Try this way,hope this will help you to solve your problem.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<ScrollView
android:id="#+id/bodyscrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp">
<LinearLayout
style="#style/app_update_alert_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
style="#style/app_update_alert_bg_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/updateinfo1" />
<TextView
style="#style/app_update_alert_bg_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/updateinfo2"
android:layout_marginTop="5dp"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#drawable/switching_image_border"
android:src="#drawable/switching_image_sb"
android:layout_marginTop="5dp"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#drawable/switching_image_border"
android:src="#drawable/switching_image_ucc"
android:layout_marginTop="5dp"/>
<CheckBox
android:id="#+id/chckbox_dontshow_again"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="#drawable/custom_checkbox"
android:text="#string/updateinfo_dontshow"
android:layout_marginTop="5dp"/>
<Button
android:id="#+id/btn_updatealert_confirmation"
style="#style/buttonStyle.signInButton"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:text="OK" />
</LinearLayout>
</ScrollView>
</LinearLayout>

How to center a LinearLayout in RelativeLayout?

I would like to center a LinearLayout in a RelativeLayout but i have a problem, the margin-bottom stays attached to bottom. Here is the view :
http://nsa33.casimages.com/img/2013/03/12//130312103139937791.png
And here is the code of the layout :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/group_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/carreGlobalInterieur"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="#color/grisTresClair" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/border_deals"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/GroupLigneOne"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/grisClair"
android:orientation="vertical" >
<TextView
android:id="#+id/CategorieDeal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:text="My Category"
android:textColor="#color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" >
<TextView
android:id="#+id/nouveauPrixVert"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10.99 €"
android:textColor="#color/green"
android:textStyle="bold" />
<TextView
android:id="#+id/ancienPrixRouge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:layout_marginRight="6dp"
android:text="20.90 €"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/red"
android:textSize="13sp"
android:textStyle="bold" />
<TextView
android:id="#+id/reductionPrix"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="4dp"
android:text="(-34%)"
android:textColor="#color/red"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/ligneTwo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="3dp"
android:orientation="vertical" >
<TextView
android:id="#+id/titreEnGros"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_marginTop="3dp"
android:text="Here is an example of a compleete title in a TextView Android"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/black"
android:textSize="16sp" />
</LinearLayout>
<RelativeLayout
android:id="#+id/ligneFour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:orientation="vertical" >
<TextView
android:id="#+id/dateAjout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="il y a 2 heures" />
<TextView
android:id="#+id/siteWeb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:text="Amazon" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
If you have some ideas to center the block, please help me !
When using the RelativeLayout, you can use android:layout_centerInParent="true", which will do what it says, center it inside its parent.

Resources