I have made customized action bar, with the image button instead of using the action bar. How will i get the back button in the action bar. With the desired different title in every page. Can i get the using xml code or do i need to code inn java file.
This isthe following code i used
layout file
<LinearLayout android:layout_width="match_parent" android:layout_height="?actionBarSize" android:orientation="horizontal" > <ImageButton android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="2" android:src="@drawable/ic_left_arrow" android:background="@android:color/transparent" /> <TextView android:id="@+id/textView7" style="@style/actionbar1White" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="0.2" android:text="Edit Account Details" /> </LinearLayout>
manifest file
<activity android:name=".Personal_Details" android:theme="@style/AppTheme.NoActionBar"> </activity>
- 5 years ago
This is the very easy way to create your own Toolbar Header with the all functionality of Normal Toolbar/ ActionBar
<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true" tools:context=".BillDetailsActivity"> <android.support.design.widget.AppBarLayout android:id="@+id/app_bar" android:layout_width="match_parent" android:layout_height="wrap_content"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <LinearLayout android:id="@+id/customize_toolbar_linearLayout_ID" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/colorPrimary" android:orientation="vertical" android:popupTheme="@style/ThemeOverlay.AppCompat.Light" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <LinearLayout android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:gravity="center|left"> <ImageView android:id="@+id/back_BillDetails_ImageView_ID" android:layout_width="wrap_content" android:layout_height="match_parent" android:paddingLeft="@dimen/textSize" android:paddingRight="@dimen/textMargin" android:src="@drawable/ic_arrow_back_black_24dp" /> <TextView android:id="@+id/billName_BillDetails_TextView_ID" style="@style/toolbar_text_style" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Bill name" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingBottom="@dimen/textMargin" android:gravity="center" android:paddingLeft="@dimen/textSize"> <ImageView android:id="@+id/bill_ICON_ImageView_BillDetails_ID" android:layout_width="@dimen/lisPicSize" android:layout_height="@dimen/lisPicSize" android:src="@drawable/ic_sports" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center|left" android:orientation="vertical" android:paddingLeft="@dimen/textSize"> <TextView android:id="@+id/billTotalAmount_TextView_BillDetails_ID" style="@style/header_style" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="0dp" android:text="$300.00" android:textColor="@color/white" android:textSize="@dimen/price_Text" /> <TextView android:id="@+id/billaddDate_TextView_BillDetails_ID" style="@style/text_style" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="left|center" android:text="21 August 2018" android:padding="0dp" android:textColor="@color/buttonTextColor" android:textSize="@dimen/subtitle" /> <TextView android:id="@+id/billDate_TextView_BillDetails_ID" style="@style/text_style" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="left|center" android:text="Added by you on 21 August 2018" android:padding="0dp" android:textColor="@color/buttonTextColor" android:textSize="@dimen/subtitle" /> <TextView android:id="@+id/lastupdatedDate_TextView_BillDetails_ID" style="@style/text_style" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="left|center" android:padding="0dp" android:text="Last updated on 27 August 2018" android:textColor="@color/buttonTextColor" android:textSize="@dimen/subtitle" /> </LinearLayout> </LinearLayout> </LinearLayout> </LinearLayout> </android.support.design.widget.AppBarLayout> <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/swipe_to_refresh_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context=".GroupDetails_Activity" tools:showIn="@layout/activity_group__details"> <android.support.v4.widget.NestedScrollView 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:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="@dimen/textMargin" android:orientation="horizontal"> <View android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" /> <TextView style="@style/subtitle_textViewstyle" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:background="@drawable/tag_bg" android:gravity="center" android:paddingBottom="@dimen/textMargin" android:paddingLeft="@dimen/textSize" android:paddingRight="@dimen/textSize" android:paddingTop="@dimen/textMargin" android:text="Split Details" android:textSize="@dimen/groupbtnText" /> <View android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" /> </LinearLayout> <android.support.v7.widget.RecyclerView android:id="@+id/billhistory_RecyclerView_ID" android:layout_width="match_parent" android:layout_height="wrap_content" android:layoutAnimation="@anim/layout_animation_fall_down" android:scrollbars="none" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="@dimen/textMargin" android:orientation="horizontal"> <View android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" /> <Button style="@style/button_style" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/event_bg_btn" android:gravity="center" android:paddingBottom="@dimen/textMargin" android:paddingLeft="@dimen/textSize" android:paddingRight="@dimen/textSize" android:paddingTop="@dimen/textMargin" android:text="ADD A COMMENT" android:textColor="@color/colorPrimaryDark" android:textSize="@dimen/groupbtnText" /> <View android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" /> </LinearLayout> <Button style="@style/button_style" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="@dimen/textMargin" android:layout_weight="1" android:background="@drawable/button_bg_google" android:gravity="center" android:text="Delete Expense" android:textColor="@color/color" /> </LinearLayout> </android.support.v4.widget.NestedScrollView> </android.support.v4.widget.SwipeRefreshLayout> <android.support.design.widget.FloatingActionButton android:id="@+id/add_bill_fab_ID" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="@dimen/fab_margin" android:src="@drawable/ic_edit" app:backgroundTint="@color/color" app:layout_anchor="@id/app_bar" app:layout_anchorGravity="bottom|end" /> <!-- Adding bottom sheet after main content --> </android.support.design.widget.CoordinatorLayout>
Hot Questions