android:如何在折叠的工具栏中添加带有文本的按钮

桑托什·耶迪迪

如何实现以下布局。没有添加按钮,我可以实现。但是,当向上滚动时,如何添加添加按钮和添加按钮应随图像的视差一起消失。

我发现的是浮动操作按钮没有添加文本的功能。我只需要使用按钮。

在此处输入图片说明

我的xml布局没有添加按钮:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layoutplace1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/coordinatorLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/appBarLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true">

            <android.support.design.widget.CollapsingToolbarLayout
                android:id="@+id/collapsing_toolbar"
                android:layout_width="match_parent"
                android:layout_height="150dip"
                android:fitsSystemWindows="true"
                app:contentScrim="?attr/colorPrimary"
                app:expandedTitleMarginBottom="20dp"
                app:expandedTitleMarginEnd="64dp"
                app:expandedTitleMarginStart="48dp"
                app:layout_scrollFlags="scroll|exitUntilCollapsed">

                <ImageView
                    android:id="@+id/header"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    app:layout_collapseMode="parallax" />

                <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    app:layout_collapseMode="pin"
                    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />


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

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

        <FrameLayout
            android:id="@+id/framelayout"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_gravity="bottom"

            app:layout_anchor="@+id/appBarLayout"
            app:layout_anchorGravity="bottom"
            app:layout_collapseMode="none">

            <android.support.design.widget.TabLayout
                android:id="@+id/tabLayout"
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:background="#ffffff"
                android:gravity="bottom"
                android:textAllCaps="false"
                android:theme="@style/MyCustomTabLayout"
                app:tabGravity="center"
                app:tabIndicatorColor="#574ec1"
                app:tabIndicatorHeight="2dp"
                app:tabMode="scrollable"
                app:tabSelectedTextColor="#574ec1"
                app:tabTextColor="#8A000000" />

        </FrameLayout>

        <android.support.v4.view.ViewPager
            android:id="@+id/viewPager"
            android:layout_width="match_parent"
            android:layout_height="fill_parent"
            android:paddingBottom="56dp"
            android:layout_marginTop="50dp"

            app:layout_behavior="@string/appbar_scrolling_view_behavior" />

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

    <android.support.design.widget.NavigationView
        android:id="@+id/navigation_viewplace1"
        android:layout_height="match_parent"
        android:layout_width="wrap_content"
        android:layout_gravity="start"
        android:fitsSystemWindows="false"
        app:itemTextColor="#8A000000"
        app:itemIconTint="#8A000000"
        app:menu="@menu/drawer_view" />
</android.support.v4.widget.DrawerLayout>

还有文本:“ UDUPI SRIKRISHNA TEMPLE”(双行显示)。那可能吗。

我使用添加标题

collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
        collapsingToolbar.setTitle("Udupi Sri krishna Temple");

但是标题只显示一部分,并显示...

相反,我希望它以多行显示。可能吗

哈拉瓦尔

您可以像这样添加按钮和图像

<android.support.design.widget.AppBarLayout
    android:id="@+id/appBarLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="150dip"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleMarginBottom="20dp"
        app:expandedTitleMarginEnd="64dp"
        app:expandedTitleMarginStart="48dp"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <ImageView
            android:id="@+id/header"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_collapseMode="parallax" />

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_collapseMode="pin"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="bottom|end"
            app:layout_collapseMode="parallax"
            android:orientation="horizontal">
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Button"/>
        </LinearLayout>
    </android.support.design.widget.CollapsingToolbarLayout>

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

在您的主要可滚动内容中输入以下代码

   <android.support.v4.widget.NestedScrollView
    android:id="@+id/scroll"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipToPadding="false"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

</android.support.v4.widget.NestedScrollView>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在单个活动中添加带有片段的折叠工具栏

如何在工具栏中添加带有编辑文本的搜索栏

添加带有图像的折叠工具栏

如何在Android中更改折叠工具栏的文本颜色和折叠工具栏的后退按钮颜色

如何在 React Native 中实现带有标签布局的折叠工具栏

如何在Android中删除折叠工具栏

带有viewpager和底部按钮的折叠工具栏

如何在工具栏按钮中更改文本?

android - 带有 tablayout 设置背景的折叠工具栏

如何在Android工具栏中添加按钮以搜索视图?

如何在Android的工具栏中添加刷新和搜索之类的按钮?

带有折叠工具栏的片段中的Android选项卡

CKEDITOR-带有文本的工具栏按钮

如何在React Native App中添加圆形底部可折叠工具栏?

如何在Qt的应用程序标题栏中添加带有上下文菜单的按钮?

如何将带有完成按钮的工具栏添加到UIPickerView?

如何在Android中制作折叠式工具栏?

Android:滚动时如何在折叠的工具栏中更改视图

如何在Nautilus工具栏上添加/删除按钮?

如何在jqgrid工具栏上添加刷新按钮?

Android如何在没有操作栏和工具栏的情况下返回按钮?

如何从代码中添加带有工具提示,透明背景和字形的按钮?

如何在Ionic工具栏上为所有页面添加按钮?

如何在 Intellij IDEA 中的 git 工具栏中添加按钮

如何在工具栏按钮上隐藏文本(带有TBSTYLE_LIST的TBSTYLE_EX_MIXEDBUTTONS不会隐藏文本)

如何在Android应用程序工具栏的左侧添加按钮?

如何在自定义的tinymce下拉菜单中添加工具栏按钮?

如何在“笔管”的工具栏中添加对齐按钮?

如何在材料设计中的工具栏上添加搜索按钮