In the begging android had the Action Bar as an App bar (that's why remove on the manifest) but more features were added to the Toolbar. available now in this library. 'androidx.appcompat:appcompat:1.4.1'
Last active
April 11, 2022 03:42
-
-
Save dandvl/de67fd7383b83b461da1dd882542e5d3 to your computer and use it in GitHub Desktop.
Setting up a Toolbar
This file contains 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
<androidx.appcompat.widget.Toolbar | |
android:id="@+id/my_toolbar" | |
android:layout_width="match_parent" | |
android:layout_height="?attr/actionBarSize" | |
android:background="?attr/colorPrimary" | |
android:elevation="4dp" | |
android:theme="@style/ThemeOverlay.AppCompat.ActionBar" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintHorizontal_bias="0.0" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="parent" | |
app:layout_constraintVertical_bias="0.0" | |
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> |
This file contains 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
dependencies { | |
... | |
implementation 'androidx.appcompat:appcompat:1.4.1' | |
} |
This file contains 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
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_my) | |
// Note that the Toolbar defined in the layout has the id "my_toolbar" | |
setSupportActionBar(findViewById(R.id.my_toolbar)) | |
} | |
} |
This file contains 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
<application | |
android:theme="@style/Theme.AppCompat.Light.NoActionBar" | |
android:allowBackup="true" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment