From 5d8b9f338d5ee88af787267505dd53e5d7a27b68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Fri, 19 Jan 2024 15:45:18 +0900 Subject: [PATCH] =?UTF-8?q?CollapsingToolBar=E5=AE=9F=E8=A3=85=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/feature/home/HomeTopFragment.java | 25 +++++++++++-- .../src/main/res/layout/fragment_home_top.xml | 37 +++++++++++-------- 2 files changed, 44 insertions(+), 18 deletions(-) diff --git a/feature/home/src/main/java/one/nem/lacerta/feature/home/HomeTopFragment.java b/feature/home/src/main/java/one/nem/lacerta/feature/home/HomeTopFragment.java index 0f39aa5c..be127ef1 100644 --- a/feature/home/src/main/java/one/nem/lacerta/feature/home/HomeTopFragment.java +++ b/feature/home/src/main/java/one/nem/lacerta/feature/home/HomeTopFragment.java @@ -6,10 +6,15 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import com.google.android.material.appbar.CollapsingToolbarLayout; + import java.util.ArrayList; import java.util.List; @@ -79,8 +84,7 @@ public class HomeTopFragment extends Fragment { } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_home_top, container, false); @@ -100,8 +104,23 @@ public class HomeTopFragment extends Fragment { return view; + } + + @Override + public void onViewCreated(View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + CollapsingToolbarLayout collapsingToolbarLayout = view.findViewById(R.id.collapsing_toolbar); + Toolbar toolbar = view.findViewById(R.id.toolbar); + + // Set the Toolbar + ((AppCompatActivity)getActivity()).setSupportActionBar(toolbar); + + // Set the title of the CollapsingToolbarLayout + collapsingToolbarLayout.setTitle("Title"); + } + - } String pageTitle; String pageId; ArrayList listItems; diff --git a/feature/home/src/main/res/layout/fragment_home_top.xml b/feature/home/src/main/res/layout/fragment_home_top.xml index e9544337..a70e122c 100644 --- a/feature/home/src/main/res/layout/fragment_home_top.xml +++ b/feature/home/src/main/res/layout/fragment_home_top.xml @@ -1,21 +1,28 @@ - - + android:layout_height="match_parent"> - - - - - + android:layout_height="wrap_content"> + - + - \ No newline at end of file + + + + + + + \ No newline at end of file