I have a layout called thumb_unit.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="320dp"
android:layout_height="240dp"
android:orientation="horizontal"
>
<ImageView
android:id="#+id/thumbImage"
android:layout_marginLeft="10dp"
android:layout_width="160dp"
android:layout_height="220dp"
android:scaleType="fitXY"
android:src="#drawable/app_icon"
android:layout_marginTop="20dp"/>
<LinearLayout
android:layout_width="160dp"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:orientation="vertical" >
<TextView
android:id="#+id/issueName"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:text="Summer 2012"
android:textSize="18dp"
android:layout_marginLeft="6dp"
/>
<TextView
android:id="#+id/description"
android:layout_width="match_parent"
android:layout_height="151dp"
android:layout_marginLeft="6dp"
android:text="Description"
android:textSize="14dp"
android:textStyle="italic" />
<Button
android:id="#+id/view_download"
android:layout_marginTop="5dp"
android:layout_width="80dp"
android:layout_marginLeft="5dp"
android:layout_height="30dp"
android:text="View"
android:textSize="14dp"
android:textColor="#drawable/push_button_text_color"
android:background="#drawable/push_button"
android:layout_marginBottom="40dp"
/>
</LinearLayout>
</LinearLayout>
and another layout called grid_unit.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="170dp"
android:layout_height="130dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/thumbImage"
android:layout_width="77dp"
android:layout_height="105dp"
android:src="#android:drawable/ic_menu_gallery"
android:layout_marginTop="10dp"
/>
<LinearLayout
android:layout_width="73dp"
android:layout_height="120dp"
android:orientation="vertical"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
>
<TextView
android:id="#+id/issueName"
android:layout_width="77dp"
android:layout_marginTop="5dp"
android:layout_height="30dp"
android:text="South Louisiana PnK"
android:layout_marginLeft="3dp"
android:textSize="11dp"
android:textStyle="bold" />
<TextView
android:id="#+id/productName"
android:layout_marginTop="5dp"
android:layout_width="70dp"
android:layout_height="30dp"
android:layout_marginLeft="3dp"
android:text="South Louisiana PnK"
android:textSize="9dp" />
<Button
android:id="#+id/viewButton"
android:layout_width="70dp"
android:layout_height="20dp"
android:text="View"
android:textSize="9dp"
android:textColor="#drawable/push_button_text_color"
android:background="#drawable/push_button"
android:layout_marginTop="5dp"
android:layout_marginLeft="3dp"
/>
</LinearLayout>
</LinearLayout>
and now finally, I have main activity_main.xml, I want to use the combination of these as
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="440dp"
android:orientation="vertical"
tools:context="com.mirabel.activities.MainActivity" >
<include layout="#layout/thumb_unit" android:id="#+id/main_thumb"/>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<include layout="#layout/grid_unit" android:id="#+id/left_grid"/>
<include layout="#layout/grid_unit" android:id="#+id/right_grid"/>
</LinearLayout>
</LinearLayout>
sublayout in the activity_main.xml and programatically I want to set the image, text for all these things. How to do that?
You can do it in the Activity file for activity_layout.xml in the following way:
View view = findViewById(R.id.left_grid);
ImageView image = view.findViewById(R.id.thumbImage);
image.setBackgroundResource(R.id.image)); //or whatever you wish to set
TextView text = view.findViewById(R.id.issueName);
text.setText("Whatever text you want to set);
In this way, you can access all the Views in the included layout.
Related
I am developing a screen that allows the user to create a post:
here
I want that when the user clicks on the cardview of the plus, a relative layout opens that through a recyclerview shows the various types of films, and the same thing for the other cardview with the genres of films. I don't know how to insert a layout into another layout and then use your own objects. What should I do, create an overlapping layout or do something else? I can't superimpose another layout on mine,
beacuse this happens
As you can see the related layout is below the main cardview. How could I put it on top?
Full Code:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".userProfile">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="-37dp"
android:backgroundTint="#EFE8AB"
app:cardCornerRadius="40dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/txtVal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Valutazione"
android:textColor="#color/black"
android:fontFamily="#font/amiko"
android:textSize="25dp"
android:layout_marginTop="230dp"
android:layout_alignStart="#+id/img_imgpost"
/>
<androidx.cardview.widget.CardView
android:id="#+id/imBackReg"
android:layout_width="65dp"
android:layout_height="68dp"
app:cardCornerRadius="25dp"
android:layout_marginRight="8dp"
android:layout_alignParentEnd="true"
android:layout_marginTop="60dp"
android:backgroundTint="#color/redButton2">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/ic_baseline_close_24"
/>
</androidx.cardview.widget.CardView>
<TextView
android:id="#+id/d"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Descrizione:"
android:textColor="#color/black"
android:fontFamily="#font/amiko"
android:textSize="25dp"
android:layout_marginTop="295dp"
android:layout_alignStart="#+id/img_imgpost"
/>
<EditText
android:id="#+id/txt_desc"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginRight="20dp"
android:layout_marginTop="330dp"
android:background="#color/primaryPopHome2"
android:ems="10"
android:backgroundTint="#EFE8AB"
android:gravity="top|left"
android:hint="Descrizione"
android:layout_alignStart="#+id/txtVal"
android:inputType="textMultiLine"
android:textColor="#color/black"
android:textColorHint="#b7b7b7"
/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="450dp"
android:layout_marginHorizontal="15dp"
android:background="#color/darkpost"/>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginTop="470dp"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/txtT"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tipologia:"
android:textColor="#color/black"
android:fontFamily="#font/amiko"
android:textSize="25dp"
android:layout_marginLeft="2dp"
android:layout_centerVertical="true"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:text="Tipologia scelta"
android:layout_marginTop="45dp"
android:layout_marginLeft="3dp"
/>
<androidx.cardview.widget.CardView
android:id="#+id/chooseTip"
android:layout_width="65dp"
android:layout_height="68dp"
app:cardCornerRadius="20dp"
android:layout_marginLeft="8dp"
android:layout_toEndOf="#+id/txtT"
android:layout_centerVertical="true"
android:backgroundTint="#color/darkpost">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/ic_baseline_add_24"/>
</androidx.cardview.widget.CardView>
<TextView
android:id="#+id/txtC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Categoria:"
android:layout_centerVertical="true"
android:textColor="#color/black"
android:fontFamily="#font/amiko"
android:textSize="25dp"
android:layout_marginLeft="10dp"
android:layout_toEndOf="#+id/chooseTip"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:text="Categoria scelta"
android:layout_marginTop="45dp"
android:layout_alignStart="#id/txtC"
android:layout_marginLeft="2dp"
/>
<androidx.cardview.widget.CardView
android:id="#+id/chooseCat"
android:layout_width="65dp"
android:layout_height="68dp"
app:cardCornerRadius="20dp"
android:layout_marginLeft="8dp"
android:layout_centerVertical="true"
android:layout_toEndOf="#+id/txtC"
android:backgroundTint="#color/darkpost">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/ic_baseline_add_24"/>
</androidx.cardview.widget.CardView>
</RelativeLayout>
</HorizontalScrollView>
<EditText
android:id="#+id/txt_valuta"
android:layout_width="50dp"
android:layout_height="46dp"
android:layout_marginTop="220dp"
android:layout_marginLeft="13dp"
android:layout_centerHorizontal="true"
android:background="#drawable/textview_new_style"
android:ems="10"
android:hint="0"
android:text=""
android:textSize="25dp"
android:textAlignment="center"
android:layout_toEndOf="#+id/txtVal"
android:textColor="#color/black"
android:textColorHint="#EFE8AB"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/10"
android:textSize="25dp"
android:textColor="#color/black"
android:layout_marginTop="225dp"
android:layout_marginLeft="5dp"
android:layout_toEndOf="#+id/txt_valuta"
/>
<androidx.cardview.widget.CardView
android:id="#+id/img_imgpost"
android:layout_width="140dp"
android:layout_height="150dp"
app:cardCornerRadius="30dp"
android:layout_marginLeft="20dp"
android:layout_alignParentTop="true"
android:layout_marginTop="50dp"
android:backgroundTint="#color/darkpost">
<ImageView
android:id="#+id/imgPostICV"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#color/darkpost"/>
</androidx.cardview.widget.CardView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Titolo:"
android:textColor="#color/black"
android:fontFamily="#font/amiko"
android:textSize="25dp"
android:layout_marginTop="567dp"
android:layout_alignStart="#+id/img_imgpost"
/>
<EditText
android:id="#+id/txt_titoloo"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginTop="600dp"
android:layout_marginHorizontal="5dp"
android:backgroundTint="#color/darkpost"
android:ems="10"
android:hint="Titolo"
android:layout_marginBottom="20dp"
android:inputType="textEmailAddress"
android:textColor="#color/black"
android:textColorHint="#b7b7b7"
android:layout_alignStart="#+id/d"/>
</RelativeLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/btn_invia"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginTop="660dp"
app:cardCornerRadius="15dp"
android:layout_marginBottom="10dp"
android:layout_marginHorizontal="20dp"
android:backgroundTint="#E8E1A2"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pubblica il Post"
android:textColor="#color/black"
android:layout_centerInParent="true"
android:textSize="30dp"
android:fontFamily="#font/amiko"
android:textStyle="bold"/>
</RelativeLayout>
</androidx.cardview.widget.CardView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/black"/>
</RelativeLayout>
This example could solve your problem
fragment_main.xml
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<include
android:id="#+id/innerLayout"
layout="#layout/inner_layout" />
</RelativeLayout>
inner_layout.xml
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="top_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="inner text" />
</RelativeLayout>
Now in your MainFragment class
Depending on your need you can set the visibility of the inner_layout by using the following code snippet
View innerLayout = findViewById(R.id.innerLayout);
//For hiding the innner layout dynamically
innerLayout.top_layout.setVisibility(View.GONE);
//For showing the innner layout dynamically
innerLayout.top_layout.setVisibility(View.VISIBLE);
//to set text in TextView
innerLayout.text.setText("Anything you want");
I have the below XML relativelayout... I need help to make the image always fetch to all the screen but between above name ju and below buttons.
the following ImageView parameter make the image centered.
<?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="match_parent"
android:orientation="vertical" >
<TextView android:id="#+id/nameview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFE0"
android:paddingBottom="10dp"
android:paddingTop="14dp"
android:paddingLeft="45dp"
android:fontFamily="Arial"
android:textSize="18sp"
android:textStyle="bold"
android:text="Ju" />
<ImageView android:id="#+id/SingleView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/nameview"/>
<Button
android:id="#+id/funnyBtn"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginTop="10dp"
android:layout_below="#+id/SingleView"
android:layout_alignParentLeft="true"
android:src="#drawable/smileclk"
android:background="#drawable/smileclk"
android:layout_marginLeft="25dp"
android:text="" />
<Button
android:id="#+id/test1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/SingleView"
android:layout_toRightOf="#+id/funnyBtn"
android:layout_marginLeft="15dp"
android:text="test1" />
<Button
android:id="#+id/test2Btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/SingleView"
android:layout_toRightOf="#+id/comment"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:layout_marginLeft="15dp"
android:text="test2" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="20dp"
android:layout_below="#+id/test2Btn"
android:background="#ff00ff00" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingTop="20dp"
android:padding="10dip" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Calculation" />
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#ffffff" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
this is my result for now
this is my desire output
As murtaza mentioned adding android:scaleType="fitXY" helped
<ImageView android:id="#+id/SingleView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:layout_below="#id/nameview"/>
I'm dynamically injecting rows in a container of a fragment.
But I just can't seem to get the three image buttons aligned to the right, next to each other.
Anyone an idea?
Fragment layout:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scenesScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/switchLayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/scenesTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="#style/switch_title"
android:text="#string/title_switches" />
<LinearLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="vertical">
</LinearLayout>
<TextView
android:id="#+id/statusText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"/>
</LinearLayout>
</ScrollView>
My row layout:
<?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"
android:paddingBottom="10dp">
<TextView
android:id="#+id/switch_name"
android:layout_alignParentTop="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="#style/switch_row_name"
android:text="Switch name"/>
<TextView
android:id="#+id/switch_lastSeen"
android:layout_below="#id/switch_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="#style/switch_row_lastSeen"
android:text="#string/last_seen"/>
<TextView
android:id="#+id/switch_status"
android:layout_below="#id/switch_lastSeen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="#style/switch_row_level"
android:text="#string/status"/>
<ImageButton
android:id="#+id/switch_button_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_arrow_up"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
<ImageButton
android:id="#+id/switch_button_stop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_stop"
android:layout_toLeftOf="#+id/switch_button_down"
android:layout_toStartOf="#+id/switch_button_down"
android:layout_centerVertical="true" />
<ImageButton
android:id="#+id/switch_button_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_arrow_down"
android:layout_toLeftOf="#+id/switch_button_up"
android:layout_toStartOf="#+id/switch_button_up"
android:layout_centerVertical="true" />
</RelativeLayout>
How the row looks on my phone (the same on a API 19 AVD):
How Android Studio, when designing, shows the row:
try this
<?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"
android:paddingBottom="10dp">
<TextView
android:id="#+id/switch_name"
style="#style/switch_row_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="Switch name" />
<TextView
android:id="#+id/switch_lastSeen"
style="#style/switch_row_lastSeen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/switch_name"
android:text="#string/last_seen" />
<TextView
android:id="#+id/switch_status"
style="#style/switch_row_level"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/switch_lastSeen"
android:text="#string/status" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:orientation="horizontal">
<ImageButton
android:id="#+id/switch_button_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_arrow_up" />
<ImageButton
android:id="#+id/switch_button_stop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_stop" />
<ImageButton
android:id="#+id/switch_button_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_arrow_down" />
</LinearLayout>
</RelativeLayout>
I am having a navigation drawer (sliding menu) with header set in my app. I am trying out the following for the headerView.xml
I am setting a background image to the relativeLayout from a particular URL. Instead I would like to have ImageView like below:
By doing this I can use picasso library even for background image that I receive from an URL. This way the image loading is faster I don't need to save the background to any sd card etc.
Here is what I have right now:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/LayoutforbgImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:baselineAligned="false"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/LinearLayoutforImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingLeft="5dp"
android:paddingTop="10dp"
tools:ignore="RtlSymmetry,RtlHardcoded" >
<ImageView
android:id="#+id/imageforprofile"
android:layout_width="60dp"
android:layout_height="60dp"
android:src="#drawable/profilepic" />
</LinearLayout>
<TextView
android:id="#+id/textforprofile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/LinearLayoutforImage"
android:gravity="left"
android:paddingLeft="5dp"
android:paddingTop="16dp"
android:text="My Name My Name"
android:textColor="#FFFFFF"
android:textStyle="bold"
tools:ignore="HardcodedText,RtlHardcoded,RtlSymmetry" />
<TextView
android:id="#+id/textforprofileemail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textforprofile"
android:layout_toRightOf="#+id/LinearLayoutforImage"
android:gravity="left"
android:paddingBottom="10dp"
android:paddingLeft="5dp"
android:text="myname#abc.com"
android:textColor="#FFFFFF"
android:textStyle="bold"
tools:ignore="HardcodedText,RtlHardcoded,RtlSymmetry" />
</RelativeLayout>
I am setting background image to layout for: LayoutforbgImage
using:
headerLayout = (RelativeLayout) header.findViewById(R.id.LayoutforbgImage );
BitmapDrawable background = new BitmapDrawable(decodeBase64(coverimage));
headerLayout.setBackgroundDrawable(background);
headerprofileimage = (ImageView) header.findViewById(R.id.imageforprofile);
Picasso.with(this).load(profileImage).placeholder(R.drawable.profilepic).error(R.drawable.profilepic).into(headerprofileimage);
How do I create the ImageView for background image so that it fits perfectly in the layout specified like above?
Try this layout i hope it will help you
<?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" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="#drawable/top_header_bg" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_marginRight="20dp"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
hi try the following code it will help you i didn't make any changes. i simply add an ImageView to your layout.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/LayoutforbgImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:baselineAligned="false"
android:orientation="horizontal" >
<ImageView
android:id="#+id/your_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#drawable/top_bar" />
<LinearLayout
android:id="#+id/LinearLayoutforImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingLeft="5dp"
android:paddingTop="10dp"
tools:ignore="RtlSymmetry,RtlHardcoded" >
<ImageView
android:id="#+id/imageforprofile"
android:layout_width="60dp"
android:layout_height="60dp"
android:src="#drawable/images12" />
</LinearLayout>
<TextView
android:id="#+id/textforprofile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/LinearLayoutforImage"
android:gravity="left"
android:paddingLeft="5dp"
android:paddingTop="16dp"
android:text="My Name My Name"
android:textColor="#FFFFFF"
android:textStyle="bold"
tools:ignore="HardcodedText,RtlHardcoded,RtlSymmetry" />
<TextView
android:id="#+id/textforprofileemail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textforprofile"
android:layout_toRightOf="#+id/LinearLayoutforImage"
android:gravity="left"
android:paddingBottom="10dp"
android:paddingLeft="5dp"
android:text="myname#abc.com"
android:textColor="#FFFFFF"
android:textStyle="bold"
tools:ignore="HardcodedText,RtlHardcoded,RtlSymmetry" />
</RelativeLayout>
Try this way hope it will solve your problem
<?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/topBarRelative"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" >
<ImageView
android:id="#+id/imageHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"
android:cropToPadding="false"
android:src="#drawable/right_top_bg" />
<ImageView
android:id="#+id/imageforprofile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="9dp"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginRight="9dp"
android:layout_toRightOf="#+id/imageforprofile"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/textforprofile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:text="My Name My Name"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<TextView
android:id="#+id/textforprofileemail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="myname#abc.com"
android:textColor="#FFFFFF"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_below="#+id/topBarRelative"
android:layout_margin="8dp"
android:background="#drawable/content_bg"
android:orientation="vertical" >
</LinearLayout>
</RelativeLayout>
Screen shot from Eclipse
I have the following xml
<?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"
android:background="#color/blue_bg">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical" >
<com.my.view.text.MyTextView
android:id="#+id/whyResgisterHeaderText"
style="#style/textOnBg"
android:layout_marginTop="25dp"
android:text="WHY REGISTER?"
android:textStyle="bold" />
<com.my.view.text.MyTextView
android:id="#+id/whyResgisterBodyText"
style="#style/textOnBg"
android:text="Help us keep your account safe"
android:textStyle="normal" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="5dp"
android:src="#drawable/signup_illu_why" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<Button
android:id="#+id/gotItButton"
android:layout_width="250dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:background="#drawable/btn_selector"
android:padding="0dp" />
<com.my.view.text.MyTextView
android:id="#+id/gotItText"
style="#style/textOnBg"
android:layout_marginTop="25dp"
android:text="Got it"
android:textColor="#00bcfe"
android:textSize="16dp"
android:textStyle="italic" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical" >
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#70a5b3" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<com.my.view.text.MyTextView
style="#style/textOnBg"
android:layout_toLeftOf="#+id/skipIcon"
android:text="Skip"
android:textStyle="normal" />
<ImageView
android:id="#id/skipIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="#drawable/signup_skip_icon" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
I want my screen to look like:
but it looks like:
1) why cannot I see the fotter relativeLayout (with the "skip")
2) how can I center the gotItText textView? why isn't it center with current properties?
Because your root layout is a RelativeLayout.
You should declare an ID for the first LinearLayout, and then use layout_below property on the second one. Remember, their positions are relatives so if you don't specify the location of the second Linear, it will be paint over the first one.
If you want to get one linear below the other automatically use a LinearLayout as main root.
Edited you code, replaced the custom EditTexts, and removed the styles, set new heights to the layout and it seems to be working as you want.
<?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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:id="#+id/whyResgisterHeaderText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:text="WHY REGISTER?"
android:textStyle="bold" />
<TextView
android:id="#+id/whyResgisterBodyText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Help us keep your account safe"
android:textStyle="normal" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="5dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<Button
android:id="#+id/gotItButton"
android:layout_width="250dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:padding="0dp" />
<TextView
android:id="#+id/gotItText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:text="Got it"
android:textColor="#00bcfe"
android:textSize="16dp"
android:textStyle="italic" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical" >
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#70a5b3" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/skipIcon"
android:text="Skip"
android:textStyle="normal" />
<ImageView
android:id="#id/skipIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>