My layout.xml code:
<?xml version="1.0" encoding="utf-8"?>
<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:tag="cards main container">
<android.support.v7.widget.CardView
android:id="#+id/card_view"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="210dp"
card_view:cardBackgroundColor="#color/color_white"
card_view:cardCornerRadius="10dp"
card_view:cardElevation="5dp"
card_view:cardUseCompatPadding="true">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<TextView
android:id="#+id/match_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:paddingStart="30dp"
android:paddingTop="10dp"
tools:text="2nd ODI"/>
<TextView
android:id="#+id/match_series_separator"
android:layout_toRightOf="#+id/match_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:paddingTop="10dp"
android:paddingStart="5dp"
android:text="-"
/>
<TextView
android:id="#+id/series_name"
android:layout_toRightOf="#+id/match_series_separator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:paddingStart="5dp"
android:paddingTop="10dp"
tools:text="India Tour of SriLanka,5 ODIs,2010"
/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<ImageView
android:id="#+id/team_logo_1"
android:tag="image_tag"
android:layout_alignParentStart="true"
android:layout_width="65dp"
android:layout_height="100dp"
android:layout_margin="5dp"
android:src="#drawable/matches"/>
<TextView
android:id="#+id/score_team_1"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
tools:text="100/3"
android:layout_toEndOf="#+id/team_logo_1"/>
<TextView
android:id="#+id/overs_team_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:paddingTop="50dp"
android:paddingStart="15dp"
tools:text="20"
android:layout_centerVertical="true"
android:layout_toEndOf="#+id/team_logo_1" />
<ImageView
android:id="#+id/team_logo_2"
android:layout_alignParentEnd="true"
android:tag="image_tag"
android:layout_width="65dp"
android:layout_height="100dp"
android:layout_margin="5dp"
android:src="#drawable/matches"/>
<TextView
android:id="#+id/score_team_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:textSize="20sp"
tools:text="100/3"
android:layout_toStartOf="#+id/team_logo_2"/>
<TextView
android:id="#+id/overs_team_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/score_team_2"
android:layout_centerVertical="true"
android:textSize="20sp"
android:paddingTop="50dp"
android:paddingEnd="15dp"
android:layout_toStartOf="#+id/team_logo_2"
tools:text="20"/>
</RelativeLayout>
<TextView
android:id="#+id/match_status_result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
tools:text="Match in progress/ India won by 3 wickets"/>
<TextView
android:id="#+id/target_leadby"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:layout_gravity="center_horizontal"
tools:text="Target 189/lead by 100"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
<TextView
android:paddingTop="30dp"
android:layout_below="#+id/card_view"
android:id="#+id/match_preview_summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="10"
android:textColor="#android:color/black"
android:ellipsize="end"
android:textSize="15sp"
android:text="Description of the match thats about to start cause people love to read "/>
</RelativeLayout>
ScreenShot from android studio
That's how the image is in the android studio but only the cardViews are being displayed on the phone and not the TextView with id android:layout_below="#+id/card_view"
Using LinearLayout doesn't help too.
Changing android:layout_height="wrap_content" in the parent RelativeLayout gives the same result
All the contents of the CardView are displayed
If android:layout_below="#+id/card_view" is removed the TextView is displayed behind the CardView
You should only have one child group view in Card View so make LinearLayout or RelativeLayout as a parent layout in your CardView like below layout
<android.support.v7.widget.CardView
android:id="#+id/card_view"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="210dp"
card_view:cardBackgroundColor="#color/color_white"
card_view:cardCornerRadius="10dp"
card_view:cardElevation="5dp"
card_view:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<TextView
android:id="#+id/match_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:paddingStart="30dp"
android:paddingTop="10dp"
tools:text="2nd ODI"/>
<TextView
android:id="#+id/match_series_separator"
android:layout_toRightOf="#+id/match_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:paddingTop="10dp"
android:paddingStart="5dp"
android:text="-"
/>
<TextView
android:id="#+id/series_name"
android:layout_toRightOf="#+id/match_series_separator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:paddingStart="5dp"
android:paddingTop="10dp"
tools:text="India Tour of SriLanka,5 ODIs,2010"
/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<ImageView
android:id="#+id/team_logo_1"
android:tag="image_tag"
android:layout_alignParentStart="true"
android:layout_width="65dp"
android:layout_height="100dp"
android:layout_margin="5dp"
android:src="#drawable/matches"/>
<TextView
android:id="#+id/score_team_1"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
tools:text="100/3"
android:layout_toEndOf="#+id/team_logo_1"/>
<TextView
android:id="#+id/overs_team_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:paddingTop="50dp"
android:paddingStart="15dp"
tools:text="20"
android:layout_centerVertical="true"
android:layout_toEndOf="#+id/team_logo_1" />
<ImageView
android:id="#+id/team_logo_2"
android:layout_alignParentEnd="true"
android:tag="image_tag"
android:layout_width="65dp"
android:layout_height="100dp"
android:layout_margin="5dp"
android:src="#drawable/matches"/>
<TextView
android:id="#+id/score_team_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:textSize="20sp"
tools:text="100/3"
android:layout_toStartOf="#+id/team_logo_2"/>
<TextView
android:id="#+id/overs_team_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/score_team_2"
android:layout_centerVertical="true"
android:textSize="20sp"
android:paddingTop="50dp"
android:paddingEnd="15dp"
android:layout_toStartOf="#+id/team_logo_2"
tools:text="20"/>
</RelativeLayout>
<TextView
android:id="#+id/match_status_result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
tools:text="Match in progress/ India won by 3 wickets"/>
<TextView
android:id="#+id/target_leadby"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:layout_gravity="center_horizontal"
tools:text="Target 189/lead by 100"
/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
Related
Im trying to make an app in android studio. I have a textview with a circular background. The thing is that when i install it on ta physical device the Text view goes of the screen.
Hers the preview in android studio:
The Xml 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"
android:background="#000000"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:orientation="horizontal"
android:background="#drawable/top_bar">
<TextView
android:id="#+id/textView3"
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_weight="0"
android:drawableLeft="#drawable/ic_keyboard_arrow_left_black_24dp"
/>
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:fontFamily="#font/segoeui"
android:gravity="center_vertical|start"
android:text="App name and image"
android:textColor="#FFFFFF"
android:textSize="30dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:orientation="vertical">
<TextView
android:id="#+id/textView6"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fontFamily="#font/segoeui"
android:gravity="center"
android:text="Pakistan vs Australia T20"
android:textColor="#ffff"
android:textSize="24dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1.5dp"
android:background="#ffff"
android:orientation="vertical"
android:layout_marginLeft="47dp"
android:layout_marginRight="47dp"></LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="300dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="247dp"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:fontFamily="#font/segoeui"
android:gravity="center"
android:text="Match Odds"
android:textColor="#ffff"
android:textSize="17dp" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:fontFamily="#font/segoeui"
android:paddingLeft="10dp"
android:text="Favourite"
android:textColor="#ffff"
android:textSize="17dp" />
</LinearLayout>
<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:layout_marginLeft="5dp"
android:layout_marginTop="30dp"
android:orientation="horizontal">
<TextView
android:id="#+id/textView12"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="0"
android:textColor="#ffff"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView11"
android:layout_width="20dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="-"
android:textColor="#ffff"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView10"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="0"
android:textColor="#ffff"
android:textSize="20dp"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="#+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginTop="30dp"
android:fontFamily="#font/segoeui"
android:gravity="center"
android:text="WestIndies"
android:textColor="#ffff"
android:textSize="16dp"
android:visibility="visible" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<TextView
android:id="#+id/textView4"
android:layout_width="100dp"
android:layout_height="1dp"
android:layout_marginLeft="6dp"
android:background="#color/margins"
android:text="TextView" />
<TextView
android:id="#+id/textView7"
android:layout_width="100dp"
android:layout_height="1dp"
android:layout_marginLeft="30dp"
android:background="#color/margins"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:fontFamily="#font/segoeui"
android:gravity="center"
android:text="Session"
android:textColor="#ffff"
android:textSize="17dp" />
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:fontFamily="#font/segoeui"
android:gravity="center"
android:text="Runs/Balls"
android:textColor="#ffff"
android:textSize="17dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:orientation="horizontal">
<TextView
android:id="#+id/textView17"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="0"
android:textColor="#FF0000"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView18"
android:layout_width="20dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="-"
android:textColor="#ffff"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView19"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="0"
android:textColor="#ffff"
android:textSize="20dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="0dp"
android:orientation="vertical"
>
<TextView
android:id="#+id/TextViewID"
android:layout_width="110dp"
android:layout_height="110dp"
android:layout_marginTop="80dp"
android:layout_marginLeft="35dp"
android:background="#drawable/green_circle"
android:gravity="center"
android:text="2"
android:textColor="#ff2800"
android:textSize="13sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
What im getting on the screen:
ive tried using different devices with different screen sizes but all give the same result. How can i solve this.
TIA..!!!
I think it's because the LinearLayout where that round TextView is, is actually a child of another LinearLayout with horizontal orientation, and you have another empty LinearLayout of width 250dp right before it, which pushes the relevant layout out of screen. Can you try removing the empty LinearLayout and see if it helps?
In an activity adding listing view on button click.
In the main view on saving click, I need to save all listing data same time.
this is my main view where adding the list
<layout
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:paddingBottom="10dp"
android:background="#color/black"
android:layout_height="match_parent">
<include layout="#layout/toolbar_text" android:id="#+id/mytool"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginBottom="10dp"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/layoutRoot"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="10dp"
android:background="#color/colorPrimary"
android:layout_marginTop="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="15dp"
android:layout_marginStart="15dp">
<TextView
android:id="#+id/txtMeal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Protocol is for"/>
<!-- <ImageView
android:id="#+id/ivDelete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/iv_delete"
android:onClick="onClick"
android:layout_alignParentRight="true" />-->
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="15dp"
android:layout_marginTop="10dp"
android:background="#drawable/edit_gradient"
android:layout_marginEnd="20dp">
<!-- <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#null"
android:paddingTop="5dp"
android:text="My self"
android:paddingBottom="5dp"
android:paddingStart="15dp"
android:textSize="14sp"
android:layout_centerVertical="true"
android:singleLine="true"
android:textColor="#color/white" />-->
<Spinner
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:id="#+id/spinProtocol"
android:layout_alignParentRight="true">
</Spinner>
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Start date"
android:layout_marginStart="15dp"
android:layout_marginTop="15dp"
android:textColor="#color/white"/>
<RelativeLayout
android:id="#+id/rlStartDate"
android:layout_width="match_parent"
android:onClick="onClick"
android:layout_height="60dp"
android:layout_marginStart="15dp"
android:layout_marginTop="10dp"
android:background="#drawable/edit_gradient"
android:layout_marginEnd="20dp">
<TextView
android:id="#+id/txtStartDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#null"
android:paddingTop="5dp"
android:text="select date"
android:paddingBottom="5dp"
android:paddingStart="15dp"
android:textSize="14sp"
android:layout_centerVertical="true"
android:singleLine="true"
android:textColor="#color/white" />
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/calendar"
android:layout_marginEnd="15dp"
android:id="#+id/imgProStartDate"
android:tint="#color/red"
android:layout_centerVertical="true"
android:layout_alignParentRight="true">
</ImageView>
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="End date"
android:layout_marginStart="15dp"
android:layout_marginTop="15dp"
android:textColor="#color/white"/>
<RelativeLayout
android:id="#+id/rlEndDate"
android:layout_width="match_parent"
android:onClick="onClick"
android:layout_height="60dp"
android:layout_marginStart="15dp"
android:layout_marginTop="10dp"
android:background="#drawable/edit_gradient"
android:layout_marginEnd="20dp">
<TextView
android:id="#+id/txtEndDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#null"
android:paddingTop="5dp"
android:text="end date"
android:paddingBottom="5dp"
android:paddingStart="15dp"
android:textSize="14sp"
android:layout_centerVertical="true"
android:singleLine="true"
android:textColor="#color/white" />
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/calendar"
android:layout_marginEnd="15dp"
android:id="#+id/imgProEndDate"
android:tint="#color/red"
android:layout_centerVertical="true"
android:layout_alignParentRight="true">
</ImageView>
</RelativeLayout>
</LinearLayout>
<!--Workout selected lisating -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="10dp"
android:background="#color/colorPrimary"
android:layout_marginTop="5dp">
<LinearLayout
android:id="#+id/viewLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="10dp">
</LinearLayout>
<Button
android:id="#+id/btnAddMeal"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="15dp"
android:text="ADD MORE WORKOUT"
android:textColor="#color/white"
android:onClick="onClick"
android:layout_gravity="center_horizontal"/>
</LinearLayout>
<!--<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/layout_workout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="10dp"
android:background="#color/colorPrimary"
android:layout_marginTop="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Workout Name: 1"
android:id="#+id/workout_name"
android:layout_marginStart="5dp"
android:layout_marginTop="15dp"
android:textColor="#color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="15dp"
android:layout_alignEnd="#+id/workout_name"
android:textColor="#color/white"/>
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/ic_edit_white"
android:layout_marginEnd="15dp"
android:id="#+id/ivEdit"
android:layout_marginTop="15dp"/>
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:src="#drawable/ic_close"
android:layout_marginEnd="15dp"
android:id="#+id/ivDelelte"
android:layout_marginTop="15dp"
android:tint="#color/white"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/_30sdp"
android:background="#color/red">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_10sdp"
android:text="Excercise"
android:layout_weight="2"
android:layout_gravity="center"
android:textColor="#color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sets"
android:layout_weight="1"
android:layout_gravity="center"
android:textColor="#color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Reps"
android:layout_weight="1"
android:layout_gravity="center"
android:textColor="#color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rest(s)"
android:layout_weight="1"
android:layout_gravity="center"
android:textColor="#color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Temp"
android:layout_weight="1"
android:layout_gravity="center"
android:textColor="#color/white"/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/_5sdp"
tools:listitem="#layout/user_workout_list"
android:id="#+id/selected_excercise_list"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+ Add Excercises"
android:id="#+id/add_excercise"
android:layout_marginStart="15dp"
android:layout_marginTop="15dp"
android:textColor="#color/red"/>
</LinearLayout>
</LinearLayout>-->
<!--Workout name -->
<!-- <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="10dp"
android:background="#color/colorPrimary"
android:layout_marginTop="5dp">
<LinearLayout
android:id="#+id/viewLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="10dp">
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/btnAddMeal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:padding="15dp"
android:text="ADD More WORKOUT"
android:drawableStart="#drawable/add"
android:drawablePadding="5dp"
android:layout_centerHorizontal="true"
android:layout_marginStart="15dp"
android:textColor="#color/white"
android:background="#drawable/button_gray_gredient"
android:onClick="onClick"/>
</RelativeLayout>
</LinearLayout>-->
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1"
android:layout_marginStart="15dp"
android:layout_marginEnd="20dp"
android:layout_marginTop="15dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight=".50"
android:layout_gravity="center"
android:id="#+id/llDraft"
android:layout_marginEnd="10dp"
android:gravity="center"
android:background="#drawable/rect_border">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SAVE TO DRAFT"
android:fontFamily="#font/rubik_bold"
android:textColor="#color/text_color"
android:layout_gravity="center"
android:gravity="center_horizontal"/>
</LinearLayout>
<LinearLayout
android:id="#+id/llSave"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight=".50"
android:layout_gravity="center"
android:onClick="onClick"
android:gravity="center"
android:layout_marginStart="10dp"
android:background="#drawable/button_red_gredient">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SAVE "
android:fontFamily="#font/rubik_bold"
android:textColor="#color/white"
android:layout_gravity="center"
android:gravity="center_horizontal"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</layout>
And this is my listing view which I can add on button click maximum 5 views and now I need to save all listing data which added in the main view in android.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/layoutRoot"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="10dp"
android:background="#color/colorPrimary"
android:layout_marginTop="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Workout Name 1"
android:id="#+id/workout_name"
android:layout_marginStart="5dp"
android:layout_marginTop="15dp"
android:textColor="#color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="15dp"
android:layout_alignEnd="#+id/workout_name"
android:textColor="#color/white"/>
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/ic_edit_white"
android:layout_marginEnd="15dp"
android:id="#+id/ivEdit"
android:layout_marginTop="15dp"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/iv_delete"
android:padding="#dimen/_2sdp"
android:layout_marginEnd="15dp"
android:id="#+id/ivDelelte"
android:layout_marginTop="15dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/_30sdp"
android:background="#color/red">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_10sdp"
android:text="Excercise"
android:layout_weight="2"
android:layout_gravity="center"
android:textColor="#color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sets"
android:layout_weight="1"
android:layout_gravity="center"
android:textColor="#color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Reps"
android:layout_weight="1"
android:layout_gravity="center"
android:textColor="#color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rest(s)"
android:layout_weight="1"
android:layout_gravity="center"
android:textColor="#color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Temp"
android:layout_weight="1"
android:layout_gravity="center"
android:textColor="#color/white"/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/excercise_list"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+ Add Excercises"
android:id="#+id/add_program_excercise"
android:clickable="true"
android:layout_marginStart="15dp"
android:layout_marginTop="15dp"
android:textColor="#color/red"/>
</LinearLayout>
</LinearLayout>
I'm making an app where I have a cardview and inside that card view I have an imageview on that image view I'm positioning my other components.
Now my problem is as soon as I start using a layout inside image view my design editor goes blank and when removing the layout from image view the image shows again
I tried searching but I didn't get anything related to this specific problem please correct me if I'm going wrong
below is my XML
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
app:cardCornerRadius="8dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/feed_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/club1"
android:scaleType="fitCenter">
<RelativeLayout>
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/profile_image"
android:layout_width="96dp"
android:layout_height="96dp"
android:src="#drawable/ellipse"
android:layout_gravity="top|left"/>
<TextView
android:id="#+id/first_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="John Doe"
android:textSize="15sp"
android:textColor="#color/White"
android:layout_toRightOf="#+id/profile_image"/>
<TextView
android:id="#+id/second_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="checked in to"
android:textSize="9sp"
android:layout_toRightOf="#+id/first_text"
android:textColor="#color/White"/>
<TextView
android:id="#+id/third_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="W south"
android:textSize="15sp"
android:layout_toRightOf="#+id/second_text"
android:textColor="#color/White"/>
<TextView
android:id="#+id/fourth_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/first_text"
android:text="beach mumbai"
android:textSize="15sp"
android:textColor="#color/White"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="30 mins ago."
android:textColor="#color/White"
android:textSize="9sp"
android:layout_toRightOf="#+id/fourth_text"
android:layout_below="#+id/second_text"/>
</RelativeLayout>
</ImageView>
</RelativeLayout>
</android.support.v7.widget.CardView>
You just forgot to give hight width to you RelativeLayout check it
You are adding view inside ImageView
FYI
an
ImageView is not a ViewGroup you can not add view inside it
Change your layout like this
Try this
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
app:cardCornerRadius="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorAccent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="96dp"
android:layout_height="96dp"
android:src="#drawable/abc" />
<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"
android:padding="5dp">
<TextView
android:id="#+id/first_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="John Doe"
android:textColor="#color/colorPrimary"
android:textSize="15sp" />
<TextView
android:id="#+id/second_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="checked in to"
android:textColor="#color/colorPrimary"
android:textSize="9sp" />
<TextView
android:id="#+id/third_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="W south"
android:textColor="#color/colorPrimary"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:orientation="horizontal">
<TextView
android:id="#+id/fourth_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="beach mumbai"
android:textColor="#color/colorPrimary"
android:textSize="15sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/second_text"
android:layout_toRightOf="#+id/fourth_text"
android:text="30 mins ago."
android:textColor="#color/colorPrimary"
android:textSize="9sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerInParent="true"
android:padding="10dp"
android:text="reply to abc............" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerInParent="true">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_message" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="40 likes" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
Wrong ImageView close tag as well RelativeLayout height & width are missing. Please check code.
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
app:cardCornerRadius="8dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/feed_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/club1"
android:scaleType="fitCenter"></ImageView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/profile_image"
android:layout_width="96dp"
android:layout_height="96dp"
android:src="#drawable/ellipse"
android:layout_gravity="top|left" />
<TextView
android:id="#+id/first_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="John Doe"
android:textSize="15sp"
android:textColor="#color/White"
android:layout_toRightOf="#+id/profile_image" />
<TextView
android:id="#+id/second_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="checked in to"
android:textSize="9sp"
android:layout_toRightOf="#+id/first_text"
android:textColor="#color/White" />
<TextView
android:id="#+id/third_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="W south"
android:textSize="15sp"
android:layout_toRightOf="#+id/second_text"
android:textColor="#color/White" />
<TextView
android:id="#+id/fourth_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/first_text"
android:text="beach mumbai"
android:textSize="15sp"
android:textColor="#color/White" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="30 mins ago."
android:textColor="#color/White"
android:textSize="9sp"
android:layout_toRightOf="#+id/fourth_text"
android:layout_below="#+id/second_text" />
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.CardView
The problem is that you're treating ImageView like it was a ViewGroup, which it isn't. You can only nest views inside a ViewGroup. The simplest solution to your question would be to take everything you've put inside ImageView and put it inside your parent RelativeLayout like this:
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
app:cardCornerRadius="8dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/feed_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/club1"
android:scaleType="fitCenter"/>
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/profile_image"
android:layout_width="96dp"
android:layout_height="96dp"
android:src="#drawable/ellipse"
android:layout_gravity="top|left"/>
<TextView
android:id="#+id/first_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="John Doe"
android:textSize="15sp"
android:textColor="#color/White"
android:layout_toRightOf="#+id/profile_image"/>
<TextView
android:id="#+id/second_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="checked in to"
android:textSize="9sp"
android:layout_toRightOf="#+id/first_text"
android:textColor="#color/White"/>
<TextView
android:id="#+id/third_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="W south"
android:textSize="15sp"
android:layout_toRightOf="#+id/second_text"
android:textColor="#color/White"/>
<TextView
android:id="#+id/fourth_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/first_text"
android:text="beach mumbai"
android:textSize="15sp"
android:textColor="#color/White"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="30 mins ago."
android:textColor="#color/White"
android:textSize="9sp"
android:layout_toRightOf="#+id/fourth_text"
android:layout_below="#+id/second_text"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
I have some customized shape for one layout background, but some content is mixed up depends on what content i open.
I will show you now three images:
1.
2.
3.
How could i simplify this layout and if you can see, the layout size changes depends on size of text and if there is image in it.
This is how my layout looks:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:id="#+id/parent_container"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/bg_dialog"
android:fillViewport="false">
<RelativeLayout
android:id="#+id/background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#drawable/bg_status"
android:gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:orientation="vertical"
android:paddingTop="#dimen/feed_item_padding_top_bottom">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="#dimen/feed_item_padding_left_right"
android:paddingRight="#dimen/feed_item_padding_left_right">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/profilePic"
android:layout_width="#dimen/feed_item_profile_pic"
android:layout_height="#dimen/feed_item_profile_pic"
android:src="#drawable/user_profile_image"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="#dimen/feed_item_profile_info_padd"
android:paddingStart="#dimen/feed_item_profile_info_padd">
<TextView
android:id="#+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#android:color/black"
android:textSize="#dimen/feed_item_profile_name"
android:textStyle="bold"/>
<TextView
android:id="#+id/timestamp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/timestamp"
android:textSize="#dimen/feed_item_timestamp"/>
</LinearLayout>
</LinearLayout>
<TextView
android:id="#+id/txtStatusMsg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingLeft="#dimen/feed_item_status_pad_left_right"
android:paddingRight="#dimen/feed_item_status_pad_left_right"
android:paddingTop="#dimen/feed_item_status_pad_top"
android:textColor="#android:color/black"/>
<ImageView
android:id="#+id/feedImage1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#android:color/white"
android:visibility="visible"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp">
<CheckBox
android:id="#+id/btn_like"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#null"
android:button="#drawable/like_button_state"
android:padding="10dp"
android:text="#string/btn_like_text"
android:textColor="#android:color/black"/>
<TextView
android:id="#+id/tv_like"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="0"
android:textColor="#android:color/black"
android:textSize="18sp"/>
<Button
android:id="#+id/btn_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#null"
android:drawableLeft="#drawable/ic_comment"
android:drawableStart="#drawable/ic_comment"
android:padding="10dp"
android:text="#string/btn_comment_text"
android:textColor="#android:color/black"/>
<TextView
android:id="#+id/tv_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="0"
android:textColor="#android:color/black"
android:textSize="18sp"/>
<ImageButton
android:id="#+id/btn_share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#null"
android:gravity="center"
android:padding="10dp"
android:src="#drawable/ic_action_share"/>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<Button
android:id="#+id/btn_report"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#null"
android:gravity="center"
android:text="REPORT"
android:textColor="#android:color/black"/>
<TextView
android:id="#+id/tv_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/btn_report"
android:layout_alignParentTop="true"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:layout_toLeftOf="#+id/tv_category"
android:layout_toStartOf="#+id/tv_category"
android:gravity="center"
android:text="Category:"
android:textColor="#android:color/black"/>
<TextView
android:id="#+id/tv_category"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/tv_info"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:gravity="center"
android:text="#Good Night"
android:textColor="#android:color/holo_red_dark"/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>
I want to put back button on Fragment class. I want to put back button on left ShoppingMazza text .
nav_drawer_row.xml:-
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:orientation="vertical"
android:gravity="center">
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/log" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="30dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:textSize="15dp"
android:textStyle="bold"
android:onClick="shopByCategory"
android:text="Shop By Category"/>
<!-- <RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/electronic1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal"
android:layout_toEndOf="#+id/imageView1"
android:layout_toRightOf="#+id/imageView1"
android:gravity="center_vertical"
android:text="Hello" />
</RelativeLayout> -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:paddingLeft="60dp"
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/electronic1" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:textSize="15dp"
android:textStyle="bold"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal"
android:layout_toEndOf="#+id/imageView1"
android:layout_toRightOf="#+id/imageView1"
android:gravity="center_vertical"
android:text="Electronic"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:paddingLeft="60dp"
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/fashion" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:textSize="15dp"
android:textStyle="bold"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal"
android:layout_toEndOf="#+id/imageView2"
android:layout_toRightOf="#+id/imageView2"
android:gravity="center_vertical"
android:text="Fashion & Lifestyle "/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:paddingLeft="25dp"
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/deal" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:textSize="15dp"
android:textStyle="bold"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal"
android:layout_toEndOf="#+id/imageView3"
android:layout_toRightOf="#+id/imageView3"
android:gravity="center_vertical"
android:onClick="deal"
android:text="#string/today_deals"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:paddingLeft="25dp"
android:id="#+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/track" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:textSize="15dp"
android:textStyle="bold"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal"
android:layout_toEndOf="#+id/imageView4"
android:layout_toRightOf="#+id/imageView4"
android:gravity="center_vertical"
android:onClick="home"
android:text="#string/track_your_order"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:paddingLeft="25dp"
android:id="#+id/imageView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/track" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:textSize="15dp"
android:textStyle="bold"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal"
android:layout_toEndOf="#+id/imageView5"
android:layout_toRightOf="#+id/imageView5"
android:gravity="center_vertical"
android:onClick="legal"
android:text="#string/legal"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:paddingLeft="25dp"
android:id="#+id/imageView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/rate1" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:textSize="15dp"
android:textStyle="bold"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal"
android:layout_toEndOf="#+id/imageView6"
android:layout_toRightOf="#+id/imageView6"
android:gravity="center_vertical"
android:text="#string/rate_this_app"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:paddingLeft="25dp"
android:id="#+id/imageView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/query" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:textSize="15dp"
android:textStyle="bold"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal"
android:layout_toEndOf="#+id/imageView7"
android:layout_toRightOf="#+id/imageView7"
android:gravity="center_vertical"
android:onClick="query"
android:text="#string/any_other_query"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:paddingLeft="25dp"
android:id="#+id/imageView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/twitter" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:textSize="15dp"
android:textStyle="bold"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal"
android:layout_toEndOf="#+id/imageView8"
android:layout_toRightOf="#+id/imageView8"
android:gravity="center_vertical"
android:text="#string/follow_us_on_twitter"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:paddingLeft="25dp"
android:id="#+id/imageView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/fb" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:textSize="15dp"
android:textStyle="bold"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal"
android:layout_toEndOf="#+id/imageView9"
android:layout_toRightOf="#+id/imageView9"
android:gravity="center_vertical"
android:text="#string/follow_us_on_facebook"/>
</RelativeLayout>
</LinearLayout>
<TextView
android:id="#+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="30dp"
android:paddingTop="10dp"
android:text=""
android:paddingBottom="10dp"
android:textSize="15dp"
android:textStyle="bold" />
</LinearLayout>
When click on back button drawer layout is closed.Anyone can hep me how i solved my problem.
I think that it is very strange to put a back button here.because you can close drawer by slide it .But any way just put your back button like this .
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp">
<ImageView
android:layout_marginLeft="60dp"
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/electronic1" />
<ImageView
android:layout_marginLeft="10dp"
android:id="#+id/imageView"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:src="#drawable/back" />
</RelativeLayout>
First put a back button here is a bad idea, try to take a look to the google layout design.
But for your pb, you wants help for the layout ?
in your case juste create an horizontal Linear Layout, and add your button and then your image.
For the close operation we lack of information. Does you want to close the activity ?
does you want to go back to the main fragment ?
I'm a bit confused cauz it seems that you never touched android development.