Created
December 1, 2016 09:54
-
-
Save IevgenOsetrov/5623016e13ce987ceff1d4e545a3fa49 to your computer and use it in GitHub Desktop.
Custom toolbar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<TextView xmlns:android="http://schemas.android.com/apk/res/android" | |
android:id="@+id/action_save" | |
style="@style/TextSize14.Light" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:gravity="center_vertical" | |
android:paddingRight="5dp" | |
android:text="@string/action_bar_save" | |
android:textColor="@color/yellow" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | |
setSupportActionBar(toolbar); | |
getSupportActionBar().setDisplayShowTitleEnabled(false); | |
toolbar.setNavigationIcon(R.drawable.ic_back_arrow); | |
TextView titleTextView = (TextView) toolbar.findViewById(R.id.toolbar_title); | |
titleTextView.setText(getResources().getString(R.string.register)); | |
titleTextView.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
Intent intent = new Intent(RegisterActivity.this, CarrierSettingsActivity.class); | |
startActivity(intent); | |
} | |
}); | |
toolbar.setNavigationOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
finish(); | |
} | |
}); | |
} | |
@Override | |
public boolean onCreateOptionsMenu(Menu menu) { | |
getMenuInflater().inflate(R.menu.toolbar_menu, menu); | |
MenuItem item = menu.findItem(R.id.action_next).setVisible(true); | |
item.getActionView().setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
cropAndSaveImage(); | |
} | |
}); | |
return true; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.v7.widget.Toolbar | |
android:id="@+id/toolbar" | |
android:layout_width="match_parent" | |
android:layout_height="?attr/actionBarSize" | |
android:background="@color/blue" | |
android:minHeight="?attr/actionBarSize" | |
xmlns:android="http://schemas.android.com/apk/res/android"> | |
<TextView | |
android:id="@+id/toolbar_left_text" | |
style="@style/TextSize14.Light" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_gravity="left" | |
android:text="@string/action_bar_cancel" | |
android:textColor="@color/yellow" | |
android:visibility="gone"/> | |
<TextView | |
android:id="@+id/toolbar_title" | |
style="@style/RobotoLight" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_gravity="center" | |
android:text="Title" | |
android:textColor="@android:color/white" | |
android:textSize="20sp"/> | |
</android.support.v7.widget.Toolbar> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment