Hi I am implementing a toolbar, and for this I have the following code:
Activity
public class SimulationActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_simulation);
PDFView pdfView = findViewById(R.id.pdfView);
pdfView.fromAsset(SIMULATION_PDF).load();
Toolbar myToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(myToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(false);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
launchMapActivity(this);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
Layout
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".simulation.SimulationActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/white"
app:popupTheme="@style/AppTheme.PopupOverlay">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="@font/lato_black"
android:text="@string/app_name"
android:textColor="@color/red"
android:textSize="26sp" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
...
</android.support.constraint.ConstraintLayout>
Problem
If I add the TextView inside the Toolbar then the arrow's toolbar not show. Anyway, when I do click on the arrow place (it is hidden), work perfectly.
Target
Show the text view and the arrow in the toolbar.
Any idea?