滑动选项卡布局上的添加按钮 [英] Add button on Sliding Tab Layout

查看:135
本文介绍了滑动选项卡布局上的添加按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在选项卡布局"上添加一个自定义按钮.此扩展按钮将扩展我当前的标签视图.我已经实现了Google的滑动"标签中提供的所有功能.

I want to add a custom button on my Tab Layout. This expand button will expand my current tab view. I already have implemented all the functionalities given in google's sliding tab.

推荐答案

您可以在FrameLayout的帮助下完成它.

You can make it with the help of FrameLayout.

<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="280dp"
android:layout_gravity="center"
app:cardElevation="8dp"
card_view:cardCornerRadius="5dp">

<FrameLayout
    android:id="@+id/frame_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">


        <SlidingTabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#2D73A9"
            android:elevation="2dp" />

        <android.support.v4.view.ViewPager
            android:id="@+id/pager"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1" />

    </LinearLayout>

    <FrameLayout
        android:id="@+id/buttonPanel"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_gravity="top|end"
        android:layout_marginEnd="0dp"
        android:layout_marginRight="0dp">

        <Button
            android:id="@+id/expand"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/img_chart_expand"
            android:visibility="gone" />
    </FrameLayout>

</FrameLayout>

这篇关于滑动选项卡布局上的添加按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆