Well, I was trying to customize my ActionBar, it worked, but it happens that it does not fill the entire width of the screen, it is as if it were superimposed on the old one, to better understand the image below:
ThisismycustomActionBar.xmlclass:
<?xmlversion="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:weightSum="1"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#bb0000">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.85"
android:layout_gravity="center"
android:gravity="left"
android:paddingLeft="10dp"
android:text="Tarefas"
android:textSize="25dp"
android:textColor="#fff"
android:textStyle="bold"/>
<Button
android:id="@+id/btNewTask"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.15"
android:text="+"
android:textSize="50dp"
android:textColor="#fff"
android:background="@android:color/transparent"/>
</LinearLayout>
And this is my code that the custom ActionBar arrow:
public class CustomActionBar {
static Button btNewTask;
public static void setCustomActionBarView(ActionBar actionBar, LinearLayout layout, final Context context) {
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
ActionBar.LayoutParams params = new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT,
ActionBar.LayoutParams.MATCH_PARENT, Gravity.LEFT);
btNewTask = (Button) layout.findViewById(R.id.btNewTask);
btNewTask.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(context, "TESTE", Toast.LENGTH_SHORT).show();
}
});
actionBar.setCustomView(layout, params);
actionBar.setDisplayHomeAsUpEnabled(false);
}
}
Would anyone know how to solve this problem?
Att. Jeiferson