This commit is contained in:
ろむねこ 2024-01-19 16:36:44 +09:00
parent 1b050f5d3c
commit 52d2a244a0
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168
3 changed files with 31 additions and 14 deletions

View File

@ -18,8 +18,9 @@ import android.widget.TextView;
import android.widget.Toast;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.shape.CornerFamily;
import com.google.android.material.shape.MaterialShapeDrawable;
import com.google.android.material.shape.ShapeAppearanceModel;
import dagger.hilt.android.AndroidEntryPoint;
@ -55,17 +56,29 @@ public class MainActivity extends AppCompatActivity {
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// Create a new TextView
TextView toolbarTitle = new TextView(this);
// Set the text and center it in the TextView
toolbarTitle.setText("App Name");
toolbarTitle.setTextColor(Color.WHITE);
toolbarTitle.setTextSize(20);
toolbarTitle.setLayoutParams(new Toolbar.LayoutParams(Toolbar.LayoutParams.WRAP_CONTENT,
Toolbar.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL));
// // Create a new TextView
// TextView toolbarTitle = new TextView(this);
// // Set the text and center it in the TextView
// toolbarTitle.setText("App Name");
// toolbarTitle.setTextColor(Color.WHITE);
// toolbarTitle.setTextSize(20);
// toolbarTitle.setLayoutParams(new Toolbar.LayoutParams(Toolbar.LayoutParams.WRAP_CONTENT,
// Toolbar.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL));
//
// // Set the TextView as the title
// toolbar.addView(toolbarTitle);
// Set the TextView as the title
toolbar.addView(toolbarTitle);
// Create a ShapeAppearanceModel with rounded corners
ShapeAppearanceModel shapeAppearanceModel = new ShapeAppearanceModel()
.toBuilder()
.setAllCorners(CornerFamily.ROUNDED, getResources().getDimension(one.nem.lacerta.shared.ui.R.dimen.toolbar_corner_radius))
.build();
// Create a MaterialShapeDrawable with the ShapeAppearanceModel
MaterialShapeDrawable shapeDrawable = new MaterialShapeDrawable(shapeAppearanceModel);
// Set the MaterialShapeDrawable as the background of the Toolbar
toolbar.setBackground(shapeDrawable);
DrawerLayout drawer = findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(

View File

@ -22,9 +22,9 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:background="?attr/colorSecondaryContainer"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
app:titleCentered="true" />
</com.google.android.material.appbar.AppBarLayout>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="toolbar_corner_radius">16dp</dimen>
</resources>