1

sorry for my bad English ,I am create Tabs similar to whats app but how to place image background in between tab and app name when i select any tab separate image image can be visible please help me any one sample image below i need like this any one tell me please enter image description here

2 Answers2

0

Try this

set your image in AppBarLayout background.

and replace your content layout xml file.

<?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="com.example.lcom53.toolbarapp.MainActivity">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay"
    android:background="@drawable/photo"
    app:elevation="0dp">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        app:layout_scrollFlags="scroll|enterAlways"
        app:popupTheme="@style/AppTheme.PopupOverlay"
        app:elevation="0dp">


    </android.support.v7.widget.Toolbar>
    <android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="15dp"
        app:tabSelectedTextColor="#FFFFFF"
        app:tabTextAppearance="@style/MyCustomTabLayout" />
</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
Bhavesh Desai
  • 239
  • 2
  • 13
0

Add android:background="#00000000" or android:background="@drawable/img_transparent" in your appbar like this:

 <android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#00000000"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
Srikanth
  • 1,555
  • 12
  • 20