ToolBar実装 WIP

This commit is contained in:
ろむねこ 2024-01-16 11:50:50 +09:00
parent 8502bcdcab
commit d01f5b9c79
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168
3 changed files with 52 additions and 1 deletions

View File

@ -17,6 +17,7 @@ import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import com.google.android.material.appbar.MaterialToolbar;
import com.websitebeaver.documentscanner.DocumentScanner;
import java.util.ArrayList;
@ -76,6 +77,9 @@ public class ScannerManagerActivity extends AppCompatActivity {
return insets;
});
MaterialToolbar toolbar = findViewById(R.id.top_toolbar);
setSupportActionBar(toolbar);
documentScanner.startScan();
// Init
@ -83,6 +87,25 @@ public class ScannerManagerActivity extends AppCompatActivity {
}
@Override
public boolean onCreateOptionsMenu(android.view.Menu menu) {
getMenuInflater().inflate(R.menu.scanner_result_toolbar, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(android.view.MenuItem item) {
if (item.getItemId() == R.id.action_close) {
finish();
return true;
} else if (item.getItemId() == R.id.action_save) {
// TODO-rca: 保存処理
Toast.makeText(this, "保存処理", Toast.LENGTH_SHORT).show();
return true;
}
return super.onOptionsItemSelected(item);
}
private void processResult(ArrayList<Bitmap> resultImages) {
logger.debug(TAG, "processResult");

View File

@ -2,9 +2,23 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main"
android:theme="@style/Theme.Lacerta"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/top_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimaryContainer"
app:titleTextColor="@color/colorOnPrimaryContainer"
app:title="Preview"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/selected_image"
android:layout_width="match_parent"
@ -14,7 +28,7 @@
app:layout_constraintBottom_toTopOf="@+id/horizontal_scroll"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toBottomOf="@id/top_toolbar" />
<HorizontalScrollView
android:id="@+id/horizontal_scroll"

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_close"
android:icon="@drawable/close_24px"
android:title="Close"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/action_save"
android:icon="@drawable/save_24px"
android:title="Save"
app:showAsAction="ifRoom"/>
</menu>