前提
1つ目のLinearLayout内にAppbarとToolbarを書いて、2つ目のLinearLayout内にButtonを書いております。
理由としては、Appbarは画面上部に表示させて、Buttonは画面下部に表示させたいからです。
それぞれのHeightについて、
Appbar:固定
Toolbar:全体のHeight - (AppbarのHeight + ButtonのHeight)
Button:ボタン数が状況によって変化するので、それに合わせて変化します。
(ButtonはLinearLayoutの中に入れていおります。)
実現したいこと
AppbarのHeightとButtonのHeightに合わせてToolbar(タブ)がHeightを調節して表示できるようにしたいです。
表示順は上から、Appbar、Toolbar、Buttonになります。
発生している問題・エラーメッセージ
ToolbarのHeightをmatch_parentにしているため、画面下部に設定しているボタンと被ってしまいます。
該当のソースコード
xml
1<?xml version="1.0" encoding="utf-8"?> 2<androidx.coordinatorlayout.widget.CoordinatorLayout 3 xmlns:android="http://schemas.android.com/apk/res/android" 4 xmlns:app="http://schemas.android.com/apk/res-auto" 5 xmlns:tools="http://schemas.android.com/tools" 6 android:layout_width="match_parent" 7 android:layout_height="match_parent" 8 android:orientation="vertical"> 9 <LinearLayout 10 android:id="@+id/linearLayoutGuide" 11 android:orientation="vertical" 12 android:layout_width="match_parent" 13 android:layout_height="match_parent" 14 android:layout_gravity="right" 15 android:padding="5dp" 16 android:background="@drawable/border_left"> 17 <com.google.android.material.appbar.AppBarLayout 18 android:layout_width="match_parent" 19 android:layout_height="wrap_content" 20 android:theme="@style/AppTheme.AppBarOverlay" 21 app:expanded="false"> 22 <androidx.appcompat.widget.Toolbar 23 android:id="@+id/toolbar" 24 android:layout_width="match_parent" 25 android:layout_height="46dp" 26 android:background="@drawable/border_bottom" 27 android:theme="@style/AppTheme.Toolbar" 28 app:titleTextColor="@color/normalTextLight"> 29 </androidx.appcompat.widget.Toolbar> 30 </com.google.android.material.appbar.AppBarLayout> 31 <LinearLayout 32 android:id="@+id/linearLayoutGuide" 33 android:orientation="horizontal" 34 android:layout_width="match_parent" 35 android:layout_height="match_parent" 36 android:padding="5dp" 37 android:background="@drawable/border_left"> 38 39 </LinearLayout> 40 </LinearLayout> 41 <LinearLayout 42 android:id="@+id/linearLayout1" 43 android:orientation="vertical" 44 android:layout_width="match_parent" 45 android:layout_height="45dp" 46 android:layout_gravity="bottom"> 47 <Button 48 android:text="Button" 49 android:layout_width="78dp" 50 android:layout_height="48dp" 51 android:id="@+id/button1" 52 android:layout_gravity="bottom"/> 53 <Button 54 android:text="Button" 55 android:layout_width="78dp" 56 android:layout_height="48dp" 57 android:id="@+id/button1" 58 android:layout_gravity="bottom"/> 59 </LinearLayout> 60</androidx.coordinatorlayout.widget.CoordinatorLayout>
試したこと
Buttonを同じLinearLayoutに入れたりしましたが、Buttonが範囲外になってしまうか、被ってしまいます。
補足情報(FW/ツールのバージョンなど)
Microsoft Visual Studio 2019 Version 16.11.19
Microsoft .NET Framework Version 4.8.04084
MonoAndroid, Version=v9.0

回答1件
あなたの回答
tips
プレビュー