How can I make layout like this with inflated layout? - android

I inflate layout to listview and here is what I want:
But I always get something like this:
As you see, the button is always align at the bottom of parent. Here is my xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff" >
<ImageView
android:id="#+id/img_icon_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_margin="5dp" />
<TextView
android:id="#+id/txt_title_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/img_icon_type"
android:text="TextView"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="#+id/txt_post_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_title_type"
android:layout_marginTop="16dp"
android:layout_toRightOf="#+id/img_icon_type"
android:text="TextView"
android:textSize="15sp" />
<TextView
android:id="#+id/txt_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_post_time"
android:layout_toRightOf="#+id/img_icon_type"
android:text="TextView"
android:textSize="15sp" />
<ImageView
android:id="#+id/img_edit_post"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:onClick="openPostMenu"
android:src="#drawable/btn_memo_menu" />
<TextView
android:id="#+id/txt_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/img_icon_type"
android:layout_margin="10dp"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:text="TextView"
android:textSize="20sp" />
<ImageView
android:id="#+id/img_posted"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_below="#+id/txt_status"
android:layout_centerHorizontal="true"
android:src="#drawable/ic_launcher" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/img_posted"
android:layout_alignRight="#+id/img_posted"
android:layout_below="#+id/img_posted" >
<RelativeLayout
android:id="#+id/btn_confirm_route"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:background="#f2f2f2" >
<TextView
android:id="#+id/txt_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="#string/現在地からのル一トを確認" />
<ImageView
android:layout_width="20sp"
android:layout_height="20sp"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/txt_address"
android:src="#drawable/btn_memo_route_search_pressed" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
Please help me to fix this!Thank you!

Related

Custom vertical line can not show in RecyclerView

I want to create recyclerview by each list item has line vertical that custom.
But I create list item then line do not show.
custom_line
line_story_view.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="match_parent">
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="#EEEEEE"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:id="#+id/line_test" />
<View android:layout_width="10dp"
android:layout_height="10dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="45dp"
android:background="#drawable/bg_test_line" />
</RelativeLayout>
listitem
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<RelativeLayout
android:layout_width="95dp"
android:layout_height="wrap_content"
android:id="#+id/relativeLayout67">
<com.makeramen.roundedimageview.RoundedImageView
android:id="#+id/rv_profile"
android:layout_width="48dp"
android:layout_height="48dp"
app:riv_border_color="#cacaca"
app:riv_corner_radius="2dip"
android:src="#drawable/plachholder"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="25dp" />
<TextView
android:id="#+id/tvwTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Loading..."
android:textAppearance="#style/AppTheme.TextAppearance"
android:textColor="#a3a3a3"
android:textSize="12dp"
android:layout_below="#+id/rv_profile"
android:layout_alignLeft="#+id/rv_profile"
android:layout_alignStart="#+id/rv_profile"
android:layout_marginTop="10dp" />
<com.example.bestiiz.component.LineStoryView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:id="#+id/line" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/relativeLayout67"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="40dp">
<TextView
android:id="#+id/tv_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="username"
android:textSize="15sp"
android:textStyle="bold"
android:textColor="#212121" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="•"
android:id="#+id/textView73"
android:layout_alignBottom="#+id/tv_username"
android:layout_toRightOf="#+id/tv_username"
android:layout_toEndOf="#+id/tv_username"
android:layout_marginLeft="5dp"
android:textSize="12sp"
android:textColor="#BDBDBD" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/cv_profile"
android:layout_centerVertical="true"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
app:civ_border_color="#cacaca"
app:civ_border_width="0.5dp"
android:src="#drawable/plachholder" />
</RelativeLayout>
<TextView
android:id="#+id/tvwCaption"
android:focusable="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#3b3b3b"
android:textSize="13sp"
android:lineSpacingMultiplier="1.3"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:text="caption" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
picture example
When I use in my recyclerview then It is not showing line.
Thankyou and Sorry for bad english.

Can't implements Scrollview in XML

why I can not show the scroll view in my project, when run does not look scrollview in my project, do I put scrollview not quite right? How Scrollview placement should be, so that all items that are in my project can get scrollview This my XML Code
activity.xml
<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"
android:padding="5dp"
tools:context=".BoxOfficeDetailActivity" >
<ImageView
android:id="#+id/ivPosterImage"
android:layout_width="150dp"
android:layout_height="200dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"
android:maxHeight="300dp"
android:src="#drawable/large_movie_poster" />
<TextView
android:id="#+id/tvCriticsScore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvTitle"
android:layout_below="#+id/tvTitle"
android:layout_marginTop="5dp"
android:layout_toRightOf="#+id/ivPosterImage"
android:text="#string/critics_score"
android:textSize="14sp" />
<TextView
android:id="#+id/tvCast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvAudienceScore"
android:layout_below="#+id/tvAudienceScore"
android:text="#string/cast"
android:layout_marginTop="5dp"
android:textSize="14sp" />
<TextView
android:id="#+id/tvTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/ivPosterImage"
android:layout_marginLeft="8dp"
android:layout_toRightOf="#+id/ivPosterImage"
android:text="#string/movie_title"
android:layout_marginTop="5dp"
android:textSize="18sp" />
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ivPosterImage"
android:layout_marginTop="10dp"
android:id="#+id/scrollView1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
<TextView
android:id="#+id/tvAudienceScore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvCriticsScore"
android:layout_below="#+id/tvCriticsScore"
android:layout_marginTop="5dp"
android:text="#string/audi_score"
android:textSize="14sp" />
<TextView
android:id="#+id/tvSynopsis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/scrollView1"
android:layout_below="#+id/tvCriticsConsensus"
android:layout_marginTop="48dp"
android:textSize="17sp"
android:text="#string/synopsis" />
<TextView
android:id="#+id/tvCriticsConsensus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/scrollView1"
android:layout_alignTop="#+id/scrollView1"
android:text="#string/cosensus"
android:textSize="17sp" />
</RelativeLayout>
Your scrollview height should not be defined in wrap because you want it to scroll.
Also the linear inside the scroll should be in wrap for its height and have some elements inside.
Suggestion if you don't mind using linears :
<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"
android:padding="5dp"
tools:context=".BoxOfficeDetailActivity" >
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="#+id/ivPosterImage"
android:layout_width="150dp"
android:layout_height="200dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"
android:maxHeight="300dp"
android:src="#drawable/large_movie_poster" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/tvTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/ivPosterImage"
android:layout_marginLeft="8dp"
android:layout_marginTop="5dp"
android:layout_toRightOf="#+id/ivPosterImage"
android:text="#string/movie_title"
android:textSize="18sp" />
<TextView
android:id="#+id/tvCriticsScore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvTitle"
android:layout_below="#+id/tvTitle"
android:layout_marginTop="5dp"
android:layout_toRightOf="#+id/ivPosterImage"
android:text="#string/critics_score"
android:textSize="14sp" />
<TextView
android:id="#+id/tvAudienceScore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvCriticsScore"
android:layout_below="#+id/tvCriticsScore"
android:layout_marginTop="5dp"
android:text="#string/audi_score"
android:textSize="14sp" />
<TextView
android:id="#+id/tvCast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvAudienceScore"
android:layout_below="#+id/tvAudienceScore"
android:layout_marginTop="5dp"
android:text="#string/cast"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="#+id/tvCriticsConsensus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/cosensus"
android:textSize="17sp" />
<TextView
android:id="#+id/tvSynopsis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tvCriticsConsensus"
android:layout_marginTop="48dp"
android:text="#string/synopsis"
android:textSize="17sp" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
<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"
android:padding="5dp"
tools:context=".BoxOfficeDetailActivity" >
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:id="#+id/scrollView1">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<ImageView
android:id="#+id/ivPosterImage"
android:layout_width="150dp"
android:layout_height="200dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"
android:maxHeight="300dp"
android:src="#drawable/large_movie_poster" />
<TextView
android:id="#+id/tvCriticsScore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvTitle"
android:layout_below="#+id/tvTitle"
android:layout_marginTop="5dp"
android:layout_toRightOf="#+id/ivPosterImage"
android:text="#string/critics_score"
android:textSize="14sp" />
<TextView
android:id="#+id/tvCast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvAudienceScore"
android:layout_below="#+id/tvAudienceScore"
android:text="#string/cast"
android:layout_marginTop="5dp"
android:textSize="14sp" />
<TextView
android:id="#+id/tvTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/ivPosterImage"
android:layout_marginLeft="8dp"
android:layout_toRightOf="#+id/ivPosterImage"
android:text="#string/movie_title"
android:layout_marginTop="5dp"
android:textSize="18sp" />
<TextView
android:id="#+id/tvAudienceScore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvCriticsScore"
android:layout_below="#+id/tvCriticsScore"
android:layout_marginTop="5dp"
android:text="#string/audi_score"
android:textSize="14sp" />
<TextView
android:id="#+id/tvSynopsis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/scrollView1"
android:layout_below="#+id/tvCriticsConsensus"
android:layout_marginTop="48dp"
android:textSize="17sp"
android:text="#string/synopsis" />
<TextView
android:id="#+id/tvCriticsConsensus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/cosensus"
android:textSize="17sp" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>

Subtext in Listview

I have a listview with a custom adapter. I am trying to show subtext under an item. This is the xml I am using. The problem is that both TextView merge together. What can I do?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/tijd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:paddingLeft="10dp" />
<TextView
android:id="#+id/sub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_below="#id/tijd"/>
<ImageView
android:id="#+id/type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/tijd" />
</RelativeLayout>
You can try it like below,
<?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="wrap_content" >
<ImageView
android:id="#+id/type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_launcher" />
<TextView
android:id="#+id/tijd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:layout_toRightOf="#+id/type"
android:text="abcde" />
<TextView
android:id="#+id/sub"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/tijd"
android:layout_toRightOf="#+id/type"
android:text="abcd" />
</RelativeLayout>
And your output will be as,
use layout below and centerhorizontal for sub
<TextView
android:id="#+id/sub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/tijd"
android:centerHorizontal="true"
android:text="abcd" />
I think, you have to remove the centerInParent from the sub.
Try this
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="#+id/type"
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_gravity="center_vertical"
android:orientation="vertical" >
<TextView
android:id="#+id/tijd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="title" />
<TextView
android:id="#+id/sub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="subtitle" />
</LinearLayout>
</LinearLayout>
Try this :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/tijd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:text="Heading" />
<TextView
android:id="#+id/sub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/tijd"
android:layout_centerInParent="true"
android:text="Subheading" />
<ImageView
android:id="#+id/type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#id/tijd"
android:background="#drawable/ic_launcher" />
Try this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/type"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/tijd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="adad" />
<TextView
android:id="#+id/sub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="adad" />
</LinearLayout>
</LinearLayout>
Hope it will work.

How to place textview on the layout border in android?

I am trying to create an layout as shown in the figure.
In that image shipped to is attached to the border of the layout. how to overlap like that.
Here is the XML I am using to create that
<RelativeLayout
android:id="#+id/shipped_to_header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#drawable/address_blue_border" >
<TextView
android:id="#+id/tv_shipped_to"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/homebackground"
android:text="Shipped To"
android:textColor="#android:color/white" />
<TextView
android:id="#+id/tv_door_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tv_shipped_to"
android:text="22"
android:textColor="#android:color/black" />
<TextView
android:id="#+id/tv_address_line1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tv_door_no"
android:text="Delhi, India"
android:textColor="#android:color/black" />
<TextView
android:id="#+id/tv_address_line2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tv_address_line1"
android:text="Swindon Senegal BS32 8FE"
android:textColor="#android:color/black" />
</RelativeLayout>
Try this
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="8dp"
android:background="#android:color/holo_blue_bright"
android:orientation="vertical"
android:padding="10dp" >
<TextView
android:id="#+id/tv_door_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="22" />
<TextView
android:id="#+id/tv_address_line1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Delhi" />
<TextView
android:id="#+id/tv_address_line2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Some more dara" />
</LinearLayout>
<TextView
android:id="#+id/tv_shipped_to"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Ship To"
android:background="#android:color/holo_blue_dark"
android:layout_marginLeft="15dp"
/>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="#android:color/white">
<!-- This is the main content -->
<RelativeLayout
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_margin="15dp" android:background="#drawable/frame"
android:orientation="vertical" android:padding="20dp">
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Main Content" android:layout_centerInParent="true" />
</RelativeLayout>
<!-- This is the title label -->
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:background="#android:color/white" android:padding="5dp"
android:text="Testing"
android:layout_marginLeft="30dp" android:textColor="#android:color/black" />
</RelativeLayout>
You can have your answer at here and here
To obtain a layout similar to the one it's in the image you have to use command android:layout_margin with negative values.
Here is an example:
<?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" >
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="TextView" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="TextView" />
</RelativeLayout>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/relativeLayout1"
android:layout_alignParentLeft="true"
android:layout_marginBottom="-10dp"
android:text="TextView" />
</RelativeLayout>
Your image is a bit toooo small. Anyway, for that, use RelativeLayout.
<?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"
android:padding="0dp" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_margin="20dp"
android:background="#ccff00"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<!-- Your other TextViews -->
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/linearLayout1"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:background="#ccffff"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>

ScrollView not accepting multiple child

Hello I need to set scroll view in following code,and set after first relative layout but it gives me :
main.xml: IllegalStateException: ScrollView can host only one direct child
that means i cant use scrollview in multiple layout child.So how can i use scroll view inside first relative layout and cover with all inner relative layout.
Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="#drawable/page1_11"
android:layout_height="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_01" android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView android:layout_height="wrap_content"
android:layout_width="match_parent" android:src="#drawable/page1_1"
android:id="#+id/imageView1" android:layout_alignParentLeft="true" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="Shanesh COLORS App"
android:textSize="13dp" android:textStyle="bold" android:textColor="#49515F"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_below="#+id/login_rellay_01" android:id="#+id/login_rellay_02"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:src="#drawable/page1_4"
android:id="#+id/imageView1" android:layout_centerHorizontal="true" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="SIGN IN"
android:textSize="13dp" android:textStyle="bold" android:textColor="#FFFFFF"
android:layout_centerInParent="true" />
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content" android:background="#drawable/page1_2"
android:layout_centerVertical="true" android:layout_marginLeft="10dp" />
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content" android:background="#drawable/page1_3"
android:layout_centerVertical="true" android:layout_marginRight="10dp"
android:layout_alignParentRight="true" />
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_03" android:layout_below="#+id/login_rellay_02"
android:layout_width="match_parent" android:layout_height="wrap_content">
<ImageView android:layout_height="wrap_content"
android:layout_width="match_parent" android:src="#drawable/page1_5"
android:id="#+id/imgv_page1_5" android:layout_alignParentLeft="true" />
<!-- <ImageView android:layout_height="wrap_content" android:layout_below="#+id/imgv_page1_5"
android:layout_marginTop="1dp" android:layout_width="match_parent" android:src="#drawable/page1_6"
android:id="#+id/imgv_page1_6" android:layout_alignParentLeft="true" /> -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_03" android:layout_centerInParent="true"
android:layout_below="#+id/login_rellay_02" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="SIGN IN "
android:textSize="13dp" android:id="#+id/login_txvx_dwbnr_1"
android:textStyle="bold" android:textColor="#000000"
android:layout_marginLeft="10dp" android:layout_centerVertical="true" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="with your "
android:id="#+id/login_txvx_dwbnr_2" android:layout_toRightOf="#+id/login_txvx_dwbnr_1"
android:textSize="13dp" android:layout_centerVertical="true"
android:textColor="#000000" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="Shanesh Colors"
android:id="#+id/login_txvx_dwbnr_3" android:layout_toRightOf="#+id/login_txvx_dwbnr_2"
android:textSize="13dp" android:textStyle="bold"
android:layout_centerVertical="true" android:textColor="#000000" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text=" App Account "
android:id="#+id/login_txvx_dwbnr_4" android:layout_toRightOf="#+id/login_txvx_dwbnr_3"
android:textSize="13dp" android:layout_centerVertical="true"
android:textColor="#000000" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_04" android:layout_marginTop="1dp"
android:gravity="center" android:layout_below="#+id/login_rellay_03"
android:layout_width="match_parent" android:layout_height="wrap_content">
<ImageView android:layout_height="180dp"
android:layout_width="306dp" android:background="#FFFFFF" android:id="#+id/imgv_page1_6"
android:layout_centerInParent="true" />
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_04" android:layout_width="match_parent"
android:layout_height="wrap_content" android:gravity="center">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="User Name:"
android:id="#+id/login_txvx_dwbnr_5" android:layout_toRightOf="#+id/login_txvx_dwbnr_1"
android:textSize="11dp" android:layout_centerVertical="true"
android:textColor="#49515F" />
<EditText android:layout_height="40dp" android:layout_width="220dp"
android:layout_marginTop="10dp" android:layout_toRightOf="#+id/login_txvx_dwbnr_5" />
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_05" android:layout_width="match_parent"
android:layout_height="wrap_content" android:gravity="center"
android:layout_below="#+id/login_rellay_04">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text=" Password:"
android:id="#+id/login_txvx_dwbnr_5"
android:layout_toRightOf="#+id/login_txvx_dwbnr_1"
android:textSize="11dp"
android:layout_centerVertical="true"
android:textColor="#49515F" />
<EditText android:layout_height="40dp" android:layout_width="220dp"
android:layout_alignParentTop="true" android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/login_txvx_dwbnr_5" />
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_06"
android:layout_marginTop="3dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_below="#+id/login_rellay_05"
android:layout_width="match_parent">
<TextView android:layout_height="wrap_content"
android:textColor="#000000"
android:text="No Account?"
android:textStyle="bold"
android:textSize="11dp"
android:id="#+id/login_txvx_dwbnr_9"
android:layout_width="wrap_content"/>
<TextView android:text="Sign Up"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="#+id/login_txvx_signup_account"
android:textColor="#8891A2"
android:textStyle="bold"
android:layout_toRightOf="#+id/login_txvx_dwbnr_9"
android:textSize="11dp"
/></RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_07"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_below="#+id/login_rellay_06"
android:layout_width="match_parent">
<CheckBox android:layout_height="wrap_content"
android:id="#+id/checkBox1"
android:layout_below="#+id/login_txvx_signup_account"
android:layout_width="wrap_content"
android:textColor="#49515F"
android:textSize="11dp"
android:layout_marginLeft="10dp"
android:text=" Remember User Name and Password?"
/>
</RelativeLayout>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_rellay_08"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_marginTop="60dp"
android:layout_below="#+id/login_rellay_04"
android:layout_width="match_parent">
<ImageView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="#drawable/page1_8"
/>
</RelativeLayout>
</RelativeLayout>
You make the outer most element the scrollview, which will give only one child your top-level relativelayout.

Categories

Resources