为什么我的图片视图占据了大部分屏幕?我想让它占据所有的空间下面的自定义应用程序栏

lf3rwulv  于 2021-07-12  发布在  Java
关注(0)|答案(2)|浏览(326)

因此,从图像中可以看到,imageview幻灯片放映的空间图片几乎占据了整个屏幕,而我希望它:
从操作栏下方开始(您可以看到自定义应用程序栏的浅紫色)
占据这下面所有的空间。如果有人有任何想法,我将不胜感激,谢谢。图片:https://imgur.com/a/fpbcyh9

<com.google.android.material.appbar.AppBarLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     style="@style/TextColor"
     android:id="@+id/app_bar_layout" >

     <androidx.appcompat.widget.Toolbar
         android:id="@+id/toolbar"
         style="@style/TextColor"
         android:layout_width="match_parent"
         android:layout_height="?attr/actionBarSize"
         android:background="@color/colorPrimaryDark"

     android:theme="@style/ThemeOverlay.AppCompat.Dark" />
     </com.google.android.material.appbar.AppBarLayout>

     <!-- viewpager to show images -->
     <androidx.viewpager.widget.ViewPager
         android:id="@+id/viewPagerMain"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_alignParentStart="true"
         android:layout_alignParentTop="true" />

 </RelativeLayout>
bkkx9g8r

bkkx9g8r1#

你能发布你的父布局(以及相对布局)吗。我认为它没有受到适当的限制。将父级相对布局高度设置为与父级匹配。
同时设置 android:layout_alignParentTop="false"

k2arahey

k2arahey2#

你需要移除 android:layout_alignParentTop="true" 并将其替换为 android:layout_below="@+id/app_bar_layout" ```
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/TextColor"
android:id="@+id/app_bar_layout" >

 <androidx.appcompat.widget.Toolbar
     android:id="@+id/toolbar"
     style="@style/TextColor"
     android:layout_width="match_parent"
     android:layout_height="?attr/actionBarSize"
     android:background="@color/colorPrimaryDark"

 android:theme="@style/ThemeOverlay.AppCompat.Dark" />
 </com.google.android.material.appbar.AppBarLayout>

 <!-- viewpager to show images -->
 <androidx.viewpager.widget.ViewPager
     android:id="@+id/viewPagerMain"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_alignParentStart="true"
     android:layout_below="@+id/app_bar_layout"/>

相关问题