Sherlock SlidingMenu

Sherlock Sliding Menu Implementation Example is an example app, which shows how to do implementation of an Android library SlidingMenu developed by tutorialsee. It has two different aproaches. First one demonstrates left side sliding out menu with a list fragment, as a content, filled with data loaded from XML file. Second one demonstrates left side sliding out menu with a list fragment, as a content, filled with data loaded from a class.

1. MainActivity.java

package com.tutorialseesherlocksliding;

import android.content.res.Configuration;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.AutoCompleteTextView;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.MenuItem;
public class MainActivity extends SherlockFragmentActivity implements OnClickListener {

private DrawerLayout mDrawerLayout;
private RelativeLayout mDrawerList;
private ActionBarDrawerToggle mDrawerToggle;
private CharSequence mDrawerTitle;
private CharSequence mTitle;
static ActionBar actionBar;
// SLIDING MENU OPTIONS
RelativeLayout rlProfile;
RelativeLayout rlHome;
RelativeLayout rlUploads;
RelativeLayout rlSubscriptions;
RelativeLayout rlPlaylists;
RelativeLayout rlHistory;
RelativeLayout rlFav;
ImageView ivMenuFacebook;
ImageView ivMenuTwitter;
ImageView ivMenuShare;
public static AutoCompleteTextView autoComplete;
@SuppressWarnings("unused")
private Handler mHandler = new Handler();
ImageView btn_card, btn_search, btn_close;
TextView btn_logo;

public static String CUR_PAGE_TITLE = "Title";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
setContentView(R.layout.activity_main);
actionBar = getSupportActionBar();
actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.gray)));
actionBar.setCustomView(R.layout.row);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setHomeButtonEnabled(true);
actionBar.setIcon(R.drawable.listicon);
btn_card = ((ImageView) findViewById(R.id.btn_card));
btn_search = ((ImageView) findViewById(R.id.btn_search));
btn_close = ((ImageView) findViewById(R.id.btn_close));
btn_logo = ((TextView) findViewById(R.id.btn_logo));
autoComplete = ((AutoCompleteTextView) findViewById(R.id.edt_search));
btn_card.setOnClickListener(this);
btn_close.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
btn_logo.setVisibility(View.VISIBLE);
btn_card.setVisibility(View.VISIBLE);
btn_search.setVisibility(View.VISIBLE);
btn_close.setVisibility(View.GONE);
autoComplete.setVisibility(View.GONE);

}
});

btn_search.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
btn_logo.setVisibility(View.GONE);
btn_card.setVisibility(View.GONE);
btn_search.setVisibility(View.GONE);
btn_close.setVisibility(View.VISIBLE);
autoComplete.setVisibility(View.VISIBLE);
}
});



initMenu();

mTitle = mDrawerTitle = getTitle();
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

mDrawerList = (RelativeLayout) findViewById(R.id.left_drawer);

// set a custom shadow that overlays the main content when the drawer opens
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

// enable ActionBar app icon to behave as action to toggle nav drawer
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
getSupportActionBar().setHomeButtonEnabled(true);

// ActionBarDrawerToggle ties together the the proper interactions
// between the sliding drawer and the action bar app icon
mDrawerToggle = new ActionBarDrawerToggle(this, // host Activity
mDrawerLayout, // DrawerLayout object
R.drawable.ic_drawer, // nav drawer image to replace 'Up' image
R.string.drawer_open, // "open drawer" description for accessibility
R.string.drawer_close // "close drawer" description for accessibility
) {
public void onDrawerClosed(View view) {
btn_logo.setVisibility(View.VISIBLE);
btn_card.setVisibility(View.VISIBLE);
btn_search.setVisibility(View.VISIBLE);
btn_close.setVisibility(View.GONE);
autoComplete.setVisibility(View.GONE);
autoComplete.setText("");
getSupportActionBar().setTitle(mTitle);
invalidateOptionsMenu(); // creates call to
// onPrepareOptionsMenu()
}

public void onDrawerOpened(View drawerView) {
btn_logo.setVisibility(View.VISIBLE);
btn_card.setVisibility(View.VISIBLE);
btn_search.setVisibility(View.VISIBLE);
btn_close.setVisibility(View.GONE);
autoComplete.setVisibility(View.GONE);
autoComplete.setText("");
getSupportActionBar().setTitle(mDrawerTitle);
invalidateOptionsMenu(); // creates call to
//onPrepareOptionsMenu()
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);

if (savedInstanceState == null) {
switchFragment(new Category());
setSelected(rlHome);
mDrawerLayout.openDrawer(mDrawerList); // Keep drawer open by default
}

}

private void initMenu() {

rlProfile = (RelativeLayout) findViewById(R.id.rlProfile);
rlHome = (RelativeLayout) findViewById(R.id.rlHome);
rlUploads = (RelativeLayout) findViewById(R.id.rlUploads);
rlSubscriptions = (RelativeLayout) findViewById(R.id.rlSubscriptions);
rlFav = (RelativeLayout) findViewById(R.id.rlFav);
rlPlaylists = (RelativeLayout) findViewById(R.id.rlPlaylists);
rlHistory = (RelativeLayout) findViewById(R.id.rlHistory);

ivMenuFacebook = (ImageView) findViewById(R.id.ivMenuFacebook);
ivMenuTwitter = (ImageView) findViewById(R.id.ivMenuTwitter);
ivMenuShare = (ImageView) findViewById(R.id.ivMenuShare);

rlProfile.setOnClickListener(this);
rlHome.setOnClickListener(this);
rlUploads.setOnClickListener(this);
rlSubscriptions.setOnClickListener(this);
rlFav.setOnClickListener(this);
rlPlaylists.setOnClickListener(this);
rlHistory.setOnClickListener(this);

ivMenuFacebook.setOnClickListener(this);
ivMenuTwitter.setOnClickListener(this);
ivMenuShare.setOnClickListener(this);

}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
if (mDrawerLayout.isDrawerOpen(mDrawerList)) {
mDrawerLayout.closeDrawer(mDrawerList);
} else {
mDrawerLayout.openDrawer(mDrawerList);
}
}
return true;

}

@Override
public void onClick(View v) {

// update the main content by replacing fragments
Fragment newContent = new Category();
Bundle bundle = new Bundle();

if (v.getId() == R.id.rlProfile) {
// PROFILE
newContent = new UserProfile();
bundle.putString(CUR_PAGE_TITLE, "Profile");
setTitle("Profile");
setSelected(rlProfile);
} else if (v.getId() == R.id.rlHome) {
// HOME
setTitle("Home");
bundle.putString(CUR_PAGE_TITLE, "Home");
setSelected(rlHome);
} else if (v.getId() == R.id.rlUploads) {
// UPLOADS
setTitle("Uploads");
bundle.putString(CUR_PAGE_TITLE, "Uploads");
setSelected(rlUploads);
} else if (v.getId() == R.id.rlSubscriptions) {
// Subscriptions
setTitle("My Subscriptions");
bundle.putString(CUR_PAGE_TITLE, "My Subscriptions");
setSelected(rlSubscriptions);
} else if (v.getId() == R.id.rlPlaylists) {
// PLAYLISTS
setTitle("Playlists");
bundle.putString(CUR_PAGE_TITLE, "Playlists");
setSelected(rlPlaylists);
} else if (v.getId() == R.id.rlHistory) {
// HISTORY
setTitle("History");
bundle.putString(CUR_PAGE_TITLE, "History");
setSelected(rlHistory);
} else if (v.getId() == R.id.rlFav) {
// FAVOURITES
setTitle("Favourites");
bundle.putString(CUR_PAGE_TITLE, "Favourites");
setSelected(rlFav);
}

// SHARE
else if (v.getId() == R.id.ivMenuFacebook) {
// FACEBOOK
Toast.makeText(this, "Facebook pressed!", Toast.LENGTH_SHORT).show();
} else if (v.getId() == R.id.ivMenuTwitter) {
// TWITTER
Toast.makeText(this, "Twitter pressed!", Toast.LENGTH_SHORT).show();
} else if (v.getId() == R.id.ivMenuShare) {
// SHARE
Toast.makeText(this, "Share pressed!", Toast.LENGTH_SHORT).show();
}

if (newContent != null) {
newContent.setArguments(bundle);
switchFragment(newContent);
}
}

// switching fragment
private void switchFragment(Fragment fragment) {
mDrawerLayout.closeDrawer(mDrawerList);
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
}

@Override
public void setTitle(CharSequence title) {
mTitle = title;
getSupportActionBar().setTitle(mTitle);
}

// set the selected option as enabled
private void setSelected(RelativeLayout rl) {

// reset all selections
rlProfile.setSelected(false);
rlHome.setSelected(false);
rlUploads.setSelected(false);
rlSubscriptions.setSelected(false);
rlPlaylists.setSelected(false);
rlHistory.setSelected(false);
rlFav.setSelected(false);
rl.setSelected(true); // set current selection
}

// When using the ActionBarDrawerToggle, you must call it during onPostCreate() and onConfigurationChanged()
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
// Sync the toggle state after onRestoreInstanceState has occurred.
mDrawerToggle.syncState();
}

@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Pass any configuration change to the drawer toggles
mDrawerToggle.onConfigurationChanged(newConfig);
}
}

2. activity_main.xml

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <!-- mian content frame -->
    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!-- include sliding menu here -->
    <include layout="@layout/sliding_menu" />

</android.support.v4.widget.DrawerLayout>

3. sliding_menu.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/left_drawer"
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="@color/white"
    android:fillViewport="true" >

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/footer"
        android:fillViewport="true"
        android:scrollbars="none" >

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" >

                <RelativeLayout
                    android:id="@+id/rlProfile"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/list_selector"
                    android:orientation="vertical"
                    android:padding="8dp" >

                    <ImageView
                        android:id="@+id/avatar"
                        android:layout_width="42dp"
                        android:layout_height="43dp"
                        android:src="@drawable/def_profile_pic" />

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="42dp"
                        android:layout_centerVertical="true"
                        android:layout_marginLeft="15dp"
                        android:layout_toRightOf="@+id/avatar"
                        android:orientation="vertical" >

                        <TextView
                            android:id="@+id/title"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:ellipsize="end"
                            android:shadowColor="@color/grey"
                            android:shadowDx="0"
                            android:shadowDy="-1"
                            android:shadowRadius="0.5"
                            android:singleLine="true"
                            android:text="USER NAME"
                            android:textColor="@color/black"
                            android:textSize="16sp"
                            android:textStyle="bold" />

                        <TextView
                            android:id="@+id/desc"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="bottom"
                            android:layout_marginTop="4dp"
                            android:ellipsize="end"
                            android:shadowColor="@color/grey"
                            android:shadowDx="0"
                            android:shadowDy="-1"
                            android:shadowRadius="0.5"
                            android:singleLine="true"
                            android:text="user@td.com"
                            android:textColor="@color/black"
                            android:textSize="12sp" />
                    </LinearLayout>
                </RelativeLayout>

                <View
                    android:layout_width="wrap_content"
                    android:layout_height="0.1dp"
                    android:background="#D2CED0" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal" >

                    <RelativeLayout
                        android:id="@+id/rlHome"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:background="@drawable/list_selector"
                        android:clickable="true"
                        android:padding="4dp" >

                        <ImageView
                            android:id="@+id/imgHome"
                            android:layout_width="32dp"
                            android:layout_height="32dp"
                            android:layout_centerVertical="true"
                            android:padding="8dp"
                            android:src="@drawable/home" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_centerVertical="true"
                            android:layout_marginLeft="4dp"
                            android:layout_marginRight="10dp"
                            android:layout_toRightOf="@+id/imgHome"
                            android:ellipsize="end"
                            android:shadowColor="@color/grey"
                            android:shadowDx="0"
                            android:shadowDy="-1"
                            android:shadowRadius="0.5"
                            android:singleLine="true"
                            android:text="Home"
                            android:textColor="@color/black"
                            android:textSize="16sp" />
                    </RelativeLayout>

                    <View
                        android:layout_width="0.1dp"
                        android:layout_height="match_parent"
                        android:layout_marginBottom="4dp"
                        android:layout_marginTop="4dp"
                        android:background="#D2CED0" />

                    <RelativeLayout
                        android:id="@+id/rlUploads"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:background="@drawable/list_selector"
                        android:clickable="true"
                        android:padding="4dp" >

                        <ImageView
                            android:id="@+id/imgUploads"
                            android:layout_width="32dp"
                            android:layout_height="32dp"
                            android:layout_centerVertical="true"
                            android:padding="8dp"
                            android:src="@drawable/uploads" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_centerVertical="true"
                            android:layout_marginLeft="4dp"
                            android:layout_marginRight="10dp"
                            android:layout_toRightOf="@+id/imgUploads"
                            android:ellipsize="end"
                            android:shadowColor="@color/grey"
                            android:shadowDx="0"
                            android:shadowDy="-1"
                            android:shadowRadius="0.5"
                            android:singleLine="true"
                            android:text="Logout"
                            android:textColor="@color/black"
                            android:textSize="16sp" />
                    </RelativeLayout>
                </LinearLayout>

                <View
                    android:layout_width="wrap_content"
                     android:layout_height="0.1dp"
                    android:background="#D2CED0" />

                <RelativeLayout
                    android:id="@+id/rlSubscriptions"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/list_selector"
                    android:clickable="true"
                    android:paddingBottom="6dp"
                    android:paddingLeft="12dp"
                    android:paddingRight="6dp"
                    android:paddingTop="6dp" >

                  
                    <TextView
                        android:id="@+id/labelTaf"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerVertical="true"
                        android:layout_marginLeft="4dp"
                        android:layout_toRightOf="@+id/imgSubscriptions"
                        android:ellipsize="end"
                        android:shadowDx="0"
                        android:shadowDy="-1"
                        android:shadowRadius="0.5"
                        android:singleLine="true"
                        android:text="About Us"
                        android:textColor="@color/black"
                        android:textSize="16sp" />
                </RelativeLayout>

                <View
                    android:layout_width="wrap_content"
                    android:layout_height="0.1dp"
                    android:layout_marginLeft="5dp"
                    android:layout_marginRight="5dp"
                    android:background="#D2CED0" />

                <RelativeLayout
                    android:id="@+id/rlPlaylists"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/list_selector"
                    android:clickable="true"
                    android:paddingBottom="6dp"
                    android:paddingLeft="12dp"
                    android:paddingRight="6dp"
                    android:paddingTop="6dp" >

                 
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerVertical="true"
                        android:layout_marginLeft="4dp"
                        android:layout_toRightOf="@+id/imgPlaylists"
                        android:ellipsize="end"
                        android:shadowDx="0"
                        android:shadowDy="-1"
                        android:shadowRadius="0.5"
                        android:singleLine="true"
                        android:text="Hardware"
                        android:textColor="@color/black"
                        android:textSize="16sp" />
                </RelativeLayout>

                <View
                    android:layout_width="wrap_content"
                     android:layout_height="0.1dp"
                    android:layout_marginLeft="5dp"
                    android:layout_marginRight="5dp"
                    android:background="#D2CED0" />

                <RelativeLayout
                    android:id="@+id/rlHistory"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/list_selector"
                    android:clickable="true"
                    android:paddingBottom="6dp"
                    android:paddingLeft="12dp"
                    android:paddingRight="6dp"
                    android:paddingTop="6dp" >

                  

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerVertical="true"
                        android:layout_marginLeft="4dp"
                        android:layout_toRightOf="@+id/imgHistory"
                        android:ellipsize="end"
                        android:shadowDx="0"
                        android:shadowDy="-1"
                        android:shadowRadius="0.5"
                        android:singleLine="true"
                        android:text="History"
                        android:textColor="@color/black"
                        android:textSize="16sp" />
                </RelativeLayout>

                <View
                    android:layout_width="wrap_content"
                    android:layout_height="0.1dp"
                    android:layout_marginLeft="5dp"
                    android:layout_marginRight="5dp"
                    android:background="#D2CED0" />

                <RelativeLayout
                    android:id="@+id/rlFav"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/list_selector"
                    android:clickable="true"
                    android:paddingBottom="6dp"
                    android:paddingLeft="12dp"
                    android:paddingRight="6dp"
                    android:paddingTop="6dp" >

                  

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerVertical="true"
                        android:layout_marginLeft="4dp"
                        android:layout_toRightOf="@+id/imgFav"
                        android:ellipsize="end"
                        android:shadowDx="0"
                        android:shadowDy="-1"
                        android:shadowRadius="0.5"
                        android:singleLine="true"
                        android:text="Contact Us"
                        android:textColor="@color/black"
                        android:textSize="16sp" />
                </RelativeLayout>

                <View
                    android:layout_width="wrap_content"
                    android:layout_height="0.1dp"
                    android:layout_marginLeft="5dp"
                    android:layout_marginRight="5dp"
                    android:background="#D2CED0" />
            </LinearLayout>
        </RelativeLayout>
    </ScrollView>

    <LinearLayout
        android:id="@+id/footer"
        android:layout_width="match_parent"
        android:layout_height="42dp"
        android:layout_alignParentBottom="true"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/ivMenuFacebook"
            android:layout_width="wrap_content"
            android:layout_height="40dp"
            android:layout_gravity="center"
            android:layout_weight="1"
            android:background="@drawable/fb_selector"
            android:padding="7dp"
            android:src="@drawable/menu_fb_icon" />

        <ImageView
            android:id="@+id/ivMenuTwitter"
            android:layout_width="wrap_content"
            android:layout_height="40dp"
            android:layout_gravity="center"
            android:layout_weight="1"
            android:background="@drawable/twt_selector"
            android:padding="7dp"
            android:visibility="gone"
            android:src="@drawable/menu_twt_icon" />

        <ImageView
            android:id="@+id/ivMenuShare"
            android:layout_width="wrap_content"
            android:layout_height="40dp"
            android:layout_gravity="center"
            android:layout_weight="1"
            android:background="@drawable/share_selector"
            android:padding="7dp"
              android:visibility="gone"
            android:src="@drawable/menu_share_icon" />
    </LinearLayout>

</RelativeLayout>

4. 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:orientation="vertical" >

    <RelativeLayout
        android:id="@+id/realtive_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#FAFAFA" >

        <ImageView
            android:id="@+id/btn_card"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:background="@null"
            android:contentDescription="@drawable/msg"
            android:padding="5dp"
            android:src="@drawable/msg"
            android:visibility="visible" />

        <TextView
            android:id="@+id/row_title"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:gravity="center"
            android:padding="10dp"
            android:text="My Orders"
            android:textColor="@color/white"
            android:textSize="20sp"
            android:textStyle="bold"
            android:visibility="gone" />

        <AutoCompleteTextView
            android:id="@+id/edt_search"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:layout_marginRight="30dp"
            android:completionThreshold="3"
            android:hint="Search"
            android:padding="18dp"
            android:textColor="@android:color/black"
            android:visibility="gone" />

        <ImageView
            android:id="@+id/btn_close"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:background="@null"
            android:contentDescription="@drawable/closes"
            android:padding="8dp"
            android:src="@drawable/closes"
            android:visibility="gone" />

        <ImageView
            android:id="@+id/btn_search"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:layout_marginLeft="30dp"
            android:layout_marginRight="30dp"
            android:background="@null"
            android:contentDescription="@drawable/search"
            android:padding="5dp"
            android:src="@drawable/search"
            android:visibility="visible" />

        <TextView
            android:id="@+id/btn_logo"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginRight="35dp"
            android:contentDescription="@drawable/andrid"
            android:gravity="center"
            android:padding="8dp"
            android:text="Tutorialsee"
            android:textColor="@android:color/black"
            android:textSize="20sp"
            android:visibility="visible" />
    </RelativeLayout>

</LinearLayout>