タイトルを中央へ WIP

This commit is contained in:
ろむねこ 2024-01-19 16:12:41 +09:00
parent 83806e0d90
commit 10019cb86b
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168

View File

@ -13,6 +13,8 @@ import androidx.navigation.ui.NavigationUI;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.material.bottomnavigation.BottomNavigationView;
@ -53,6 +55,18 @@ 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));
// Set the TextView as the title
toolbar.addView(toolbarTitle);
DrawerLayout drawer = findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, one.nem.lacerta.shared.ui.R.string.placeholder, one.nem.lacerta.shared.ui.R.string.placeholder);