简体   繁体   English

我在XML布局方面遇到了一些问题

[英]I have some problems with the XML layouts

I have a problem with the display of the “viewPager”. 我对“viewPager”的显示有问题。 I want it to be below the tabs. 我希望它低于标签。 Because now the tabs bar overlaps the display of my pictures . 因为现在标签栏与我的图片显示重叠。

Please help me Thank you, 请帮帮我谢谢

https://imgur.com/knaPFV6 https://imgur.com/knaPFV6

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|enterAlways"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

    <android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:layout_gravity="center"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabGravity="fill"
        app:tabMode="fixed" />

</android.support.design.widget.AppBarLayout>


    <android.support.v4.view.ViewPager
        android:id="@+id/viewPager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/adView"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />


<com.google.android.gms.ads.AdView
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_alignParentBottom="true"
    ads:adSize="SMART_BANNER"
    ads:adUnitId="ca-app-pub-3940256099942544/6300978111">

</com.google.android.gms.ads.AdView>

</RelativeLayout>

Make it like this. 就这样吧。 Move your View Pager inside AppBarLayout and give android:layout_above="@+id/adView" property to AppBarLayout and you will get desired output. AppBarLayout移动您的View Pager并将android:layout_above="@+id/adView"属性提供给AppBarLayout ,您将获得所需的输出。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/adView"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary" />

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            app:tabGravity="fill"
            app:tabMode="fixed"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center" />

        <android.support.v4.view.ViewPager
            android:id="@+id/viewPager"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </android.support.design.widget.AppBarLayout>

    <com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="ca-app-pub-3940256099942544/6300978111">

    </com.google.android.gms.ads.AdView>

</RelativeLayout>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 XML布局(Android开发)存在一些问题。 - I have some problems with the XML layouts (android development). XML布局有一些问题(Android开发) - Having some problems with the XML layouts (android development) 我的DrawerLayout有一些问题 - I have some problems with DrawerLayout 我在 Android Studio 中的 ActionBarActivity 有一些问题 - I have some problems with ActionBarActivity in Android Studio SharedPreferences有一些问题 - SharedPreferences have some problems 是否可以使用多个xml布局进行一个活动? - Is it possible to have one activity with multiple xml layouts? 如何以编程方式更改这些视图布局? 我在 xml 文件中有视图,但后来想以编程方式更改它们的大小 - How to change these views layouts programmatically? I have the views in xml file, but later want to change their size programmatically Android:我对 TextViews 的选取框功能有一些问题 - Android: I have some problems with the marquee-feature of TextViews Android studio 3.1 XML预览未显示某些XML布局 - Android studio 3.1 XML preview not showing for some XML layouts xml布局有问题,正在创建多个相对布局 - having problems with the xml layout, multiple relative layouts are being created
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM