remove background color of spinner's title located on the action bar



I am posting the picture of the output that i am getting where my spinner's background is set to white color but the item's title that is selected from the spinner dropdown which appears on the action bar also gets its background color set to white, so how do i remove it?


I have tried all the possible ways, like changing the style in styles folder and also by changing the theme in manifest file. any help.![enter image description here][1]



[1]: http://ift.tt/13YbPxe


My code , as i am creating action bar drop down navigation



/* ACTION BAR : OVERFLOW MENU */
getOverflowMenu();

/* for navigation menu */

actionBar = getActionBar();

// Hide the action bar title

actionBar.setDisplayShowTitleEnabled(false);actionBar.getSelectedNavigationIndex();

// Back Button

getActionBar().setDisplayHomeAsUpEnabled(true);

// Enabling Spinner dropdown navigation


actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

// Spinner title navigation data


navSpinner = new ArrayList<SpinnerNavItem>();
navSpinner.add(new SpinnerNavItem("Drinks", R.drawable.menu_drinks_icon));
navSpinner.add(new SpinnerNavItem("Home", R.drawable.home_icon));
navSpinner.add(new SpinnerNavItem("Recipes", R.drawable.menu_recipes_icon));
navSpinner.add(new SpinnerNavItem("Remedy", R.drawable.menu_remedies_icon));

// title drop down adapter


adapter = new TitleNavigationAdapter(getApplicationContext(), navSpinner);

// assigning the spinner navigation


actionBar.setListNavigationCallbacks(adapter, this);


And the Adapter code



public class TitleNavigationAdapter extends BaseAdapter {

private ImageView imgIcon;
private TextView txtTitle;
private ArrayList<SpinnerNavItem> spinnerNavItem;
private Context context;

public TitleNavigationAdapter(Context context,
ArrayList<SpinnerNavItem> spinnerNavItem) {
this.spinnerNavItem = spinnerNavItem;
this.context = context;
}


@Override
public int getCount() {
return spinnerNavItem.size();
}

@Override
public Object getItem(int index) {
return spinnerNavItem.get(index);
}


@Override
public long getItemId(int position) {
return position;
}



// for image


@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater mInflater = (LayoutInflater)
context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
convertView = mInflater.inflate(R.layout.list_item_title_navigation, null);
}
imgIcon = (ImageView) convertView.findViewById(R.id.imgIcon);
txtTitle = (TextView) convertView.findViewById(R.id.txtTitle);

imgIcon.setImageResource(spinnerNavItem.get(position).getIcon());
imgIcon.setVisibility(View.GONE);
txtTitle.setText(spinnerNavItem.get(position).getTitle());
return convertView;
}


// for text
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater mInflater = (LayoutInflater)
context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
convertView = mInflater.inflate(R.layout.list_item_title_navigation, null);
}

imgIcon = (ImageView) convertView.findViewById(R.id.imgIcon);
txtTitle = (TextView) convertView.findViewById(R.id.txtTitle);

imgIcon.setImageResource(spinnerNavItem.get(position).getIcon());
txtTitle.setText(spinnerNavItem.get(position).getTitle());
return convertView;
}

}


Xml for adapter :



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:padding="5dp"
android:background="@color/spinner_color" >

<ImageView
android:id="@+id/imgIcon"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/ic_launcher"
android:layout_marginRight="5dp"
/>

<TextView android:id="@+id/txtTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/imgIcon"
android:textColor="@color/black"
android:fontFamily="OpenSans-Regular"
android:textSize="16sp"/>

</RelativeLayout>
android:background="@color/spinner_color" `this is making the dropdown color white`

No comments:

Post a Comment