mirror of
				https://github.com/lacerta-doc/Lacerta.git
				synced 2025-10-26 21:30:48 +00:00 
			
		
		
		
	CollapsingToolBar実装テスト
This commit is contained in:
		
							parent
							
								
									9d2e5dd217
								
							
						
					
					
						commit
						5d8b9f338d
					
				| @ -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; | ||||
|  | ||||
| @ -1,21 +1,28 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:tools="http://schemas.android.com/tools" | ||||
| <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|     android:layout_width="match_parent" | ||||
|     android:layout_height="match_parent" | ||||
|     tools:context=".HomeTopFragment" | ||||
|     tools:ignore="ExtraText"> | ||||
|     android:layout_height="match_parent"> | ||||
| 
 | ||||
| 
 | ||||
|     <!-- TODO: Update blank fragment layout --> | ||||
| 
 | ||||
| 
 | ||||
|     <androidx.recyclerview.widget.RecyclerView | ||||
|         android:id="@+id/item_recycler_view" | ||||
|     <com.google.android.material.appbar.AppBarLayout | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="match_parent"> | ||||
|         android:layout_height="wrap_content"> | ||||
| 
 | ||||
|         <com.google.android.material.appbar.CollapsingToolbarLayout | ||||
|             android:id="@+id/collapsing_toolbar" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="match_parent" | ||||
|             app:layout_scrollFlags="scroll|exitUntilCollapsed"> | ||||
| 
 | ||||
|     </androidx.recyclerview.widget.RecyclerView> | ||||
|             <androidx.appcompat.widget.Toolbar | ||||
|                 android:id="@+id/toolbar" | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:layout_height="?attr/actionBarSize" | ||||
|                 app:layout_collapseMode="pin" /> | ||||
| 
 | ||||
| </androidx.constraintlayout.widget.ConstraintLayout> | ||||
|         </com.google.android.material.appbar.CollapsingToolbarLayout> | ||||
| 
 | ||||
|     </com.google.android.material.appbar.AppBarLayout> | ||||
| 
 | ||||
|     <!-- Your content here --> | ||||
| 
 | ||||
| </androidx.coordinatorlayout.widget.CoordinatorLayout> | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user