我不能让新的棒棒糖抽屉切换工作.
我这样做了:
void setupToolbar() {
    setToolbarAsActionBar();
    setupDrawerToggle();
}
public void setToolbarAsActionBar() {
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
}
void setupDrawerToggle() {
    drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.overview_title, R.string.overview_title) {
        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
        }
        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
        }
    };
    drawerLayout.setDrawerListener(drawerToggle);
    drawerToggle.setDrawerIndicatorEnabled(true);
    drawerToggle.syncState();
}
汉堡包图标在那里,我看到通过滑动手指滑出抽屉的动画.但是,图标无法点击.我错过了什么?
android android-appcompat android-5.0-lollipop android-toolbar
当我们向下滚动RecyclerView时,我只想让android.support.v7.widget.Toolbar变得透明,当我们向上滚动时清晰可见
这是我的代码
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinatorlayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
>
<android.support.design.widget.AppBarLayout
    android:id="@+id/appbarlayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    >
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar1"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="#ae43ff"
        />
    <ImageView
        android:id="@+id/imageview1"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:src="@drawable/unnamed"
        android:scaleType="center"
        app:layout_scrollFlags="scroll"
        />
    <!--app:layout_scrollFlags="scroll|enterAlways"-->
    <!--app:layout_collapseMode="parallax"
    app:layout_collapseParallaxMultiplier="0.7"-->
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
    android:id="@+id/recyclerview1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    android:background="#6fffc6">
</android.support.v7.widget.RecyclerView>
而我正在获得的输出
我尝试了许多不同的方法,但它不能按我的意愿工作.
我不想要我们在android.support.design.widget.CollapsingToolbarLayout中得到的效果
我想要这个视频中显示的效果
android android-toolbar android-collapsingtoolbarlayout android-appbarlayout
在此图像中,他们实现了一个带有视差 ImageView 的折叠工具栏和一个锚定到工具栏的 FAB。在我正在制作的应用程序中,我需要锚定 ImageView 而不是浮动操作按钮,同时仍然保留所有淡出和淡入动画。我该怎么做呢?
我现在的
活动主文件
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
    android:id="@+id/bar"
    android:layout_width="match_parent"
    android:layout_height="252dp"
    android:fitsSystemWindows="true">
    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleMarginBottom="32dp"
        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"
            android:background="@drawable/random"
            android:fitsSystemWindows="true"
            android:scaleType="centerCrop"
            app:layout_collapseMode="parallax" />
        <android.support.v7.widget.Toolbar
            android:id="@+id/anim_toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_collapseMode="pin"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" >
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"/>
        </android.support.v7.widget.Toolbar>
    </android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
    android:id="@+id/scrollableview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.example.sudarshan.testapp.MLRoundedImageView
    android:layout_width="152dp"
    android:layout_height="152dp"
    app:layout_anchor="@+id/bar"
    app:layout_anchorGravity="bottom|center"
    android:id="@+id/circularImage"/>
</android.support.design.widget.CoordinatorLayout>
ImageView 被锚定,但它不会像 FAB 那样消失并重新出现。
android floating-action-button android-toolbar android-collapsingtoolbarlayout
我想在工具栏中显示两个文本视图小部件。其中一个文本视图充当标题,另一个文本视图充当副标题,应放置在工具栏小部件的最右侧。
这是我为显示两个文本视图(一个在左侧,另一个在右侧)所做的 xml 代码。
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="@color/tool_bar_color"
    app:layout_scrollFlags="scroll|enterAlways"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    app:titleTextAppearance="@style/AppTheme.Toolbar.Title">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="start|center"
        android:textSize="20sp"
        android:textColor="@color/white"
        android:layout_gravity="center"
        android:textStyle="bold"
        android:text="Hello"
        android:singleLine="true"
        android:id="@+id/toolbar_title" />
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="end|center"
        android:textSize="15sp"
        android:textColor="@color/white"
        android:layout_gravity="center"
        android:textStyle="bold"
        android:text="India Hello"
        android:singleLine="true"
        android:id="@+id/toolbar_right_subtitle" />
</android.support.v7.widget.Toolbar>
在工具栏中放置两个文本视图小部件后,我没有得到所需的输出。如何完成显示两个文本视图小部件的所需输出,一个在左侧,另一个在右侧?
我有一个包含以下布局的片段,我在视图寻呼机的帮助下添加了两个片段:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
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.design.widget.TabLayout
    android:id="@+id/tab_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#2096f3"
    android:elevation="6dp"
    android:minHeight="?attr/actionBarSize"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:layout_below="@id/tab_layout"
    />
</android.support.design.widget.CoordinatorLayout>
并在代码中:
    TabLayout tabLayout = (TabLayout) rootView.findViewById(R.id.tab_layout);
    tabLayout.addTab(tabLayout.newTab().setText(tabs[0]));
    tabLayout.addTab(tabLayout.newTab().setText(tabs[1]));
    tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
    viewPager = (ViewPager) rootView.findViewById(R.id.pager);
    adapter = new MyViewPagerAdapter(getFragmentManager(),2);
    viewPager.setAdapter(adapter);
我在视图寻呼机的片段中有一个滚动视图.当我开始向下滚动时,我希望操作栏隐藏.怎么做到这一点?
我在活动中有一个工具栏,我正在添加一些片段.如何调整它得到预期的结果:
工具栏:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar     xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/background_floating_material_dark"
android:elevation="4dp"
android:paddingTop="1dp"
app:layout_scrollFlags="scroll|enterAlways">
android android-actionbar-compat android-toolbar android-coordinatorlayout
我觉得这很愚蠢,但我可能会花6个小时直接试图解决这个问题.我根本无法让我的工具栏显示在应用程序中 - 实现如下:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="de.gymnasium_beetzendorf.vertretungsplan.MainActivity">
    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">
        <android.support.v7.widget.Toolbar
            android:id="@+id/mainToolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />
    </android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
现在,我的MainActivity代码如下所示:
Toolbar mToolbar = (Toolbar) findViewById(R.id.mainToolbar);
setSupportActionBar(mToolbar);
我的style.xml看起来像这样(这与Android Studio在创建具有空活动的Application时创建的style.xml相同):
<resources>
   <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>
    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>
    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
我要添加的唯一内容是最后两项(windowActionBar,windowNoTitle),因为运行时应用程序崩溃了.
我注意到的一件事可能对其他人有帮助(他们不适合我):当我检查mToolbar == null时它返回true - 不知道为什么.该调用在setContentView之后.
根据要求显示清单(我遗漏了所有其他活动):
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.gymnasium_beetzendorf.vertretungsplan">
    <uses-permission android:name="android.permission.INTERNET" …我在工具栏中添加了一些视图,但显示了一些我想删除的左填充。
这是我的 xml 代码:
    <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.swornimlab.swornimlab.MainActivity">
    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay"
            >
            <include
                layout="@layout/layout_inside_toolbar" />
        </android.support.v7.widget.Toolbar>
    </android.support.design.widget.AppBarLayout>
    <include layout="@layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
查看我想在工具栏中添加的内容:
    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="?attr/actionBarSize">
    <LinearLayout
        android:layout_weight="1"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        >
        <TextView
            android:text="Hello, Asmin"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:gravity="left"
            android:textAppearance="@android:style/TextAppearance.DeviceDefault.Large"/>
        <TextView
            android:text="Welcome Home"
            android:layout_marginTop="10dp"
            android:gravity="left"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium"/>
    </LinearLayout>
    <ImageView
        android:layout_weight="1"
        android:src="@drawable/ic_home_vc"
        android:tint="@android:color/white"
        android:layout_alignParentRight="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/imageView2" />
</LinearLayout>
我正在尝试创建一个工具栏来保存我的应用程序中的项目。但是我的工具栏没有正确显示。
它是这样显示的  我想这样显示
我想这样显示 
 
在我的片段中
    public override void OnCreateOptionsMenu(IMenu menu, MenuInflater inflater)
    {
        inflater.Inflate(Resource.Menu.menu_RefuelingToolbar, menu);
    }
menu_RefuelingToolbar.xml
    <?xml version="1.0" encoding="utf-8" ?>
    <menu xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          tools:context=".RefuelingFragment">
          <item android:id="@+id/button_Save"
                android:icon="@drawable/ic_done_white_24dp"
                android:showAsAction="always"
                android:title="Settings" />
    </menu>
我在应用程序中使用了导航页面。我必须将字体图标设置为工具栏项。但它显示十字符号,因为我尚未设置字体系列。所以有人建议我可以在工具栏项中设置字体图标。
所以我正在为 Android 创建一个材料设计应用程序。我使用的是新的 Toolbar 而不是 ActionBar。在一项活动中,我想在工具栏下方显示选项卡。这对纵向和横向模式都适用,但在横向模式下,选项卡居中且不覆盖视图的整个宽度。
这是设计使然还是我需要知道什么?
这是我的活动的布局:
<android.support.design.widget.AppBarLayout
    android:layout_height="wrap_content"
    android:layout_width="match_parent">
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:height="?attr/actionBarSize"
        android:background="@color/primary"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:titleTextAppearance="@style/ToolbarTitle"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
    </android.support.v7.widget.Toolbar>
    <android.support.design.widget.TabLayout
        android:id="@+id/toolbar_tabs"
        android:height="?attr/actionBarSize"
        android:background="@color/primary"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_scrollFlags="scroll|enterAlways" />
</android.support.design.widget.AppBarLayout>
以下代码将其初始化为onCreate:
// Set up the toolbar
this.setSupportActionBar(mToolbar);
ActionBar ab = this.getSupportActionBar();
if (ab != null)
{
    ab.setDisplayHomeAsUpEnabled(true);
    ab.setHomeButtonEnabled(true);
    ab.setDisplayShowTitleEnabled(true);
}
// Set up the pager and tabs from the pager
mTabViewPager.setAdapter(mTabPagerAdapter);
mTabLayout.setupWithViewPager(mTabViewPager);
这mTabPagerAdapter是一个寻呼机适配器,用于保存要由文档中的选项卡显示的页面。
我正在尝试学习android材质设计。使用工具栏,我想更改弹出菜单以及文本颜色。所以我发现可以通过添加以下代码来完成
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#CCC"
    app:theme="@style/ThemeOverlay.AppCompat.Light"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Dark"
    android:elevation="4dp"
    >
</android.support.v7.widget.Toolbar>
但是问题是app:theme和app:popupTheme无法正常工作,并且在android studio xml文件中显示错误。
我能知道些什么?
我正在使用com.android.support:appcompat-v7:23.0.0
android-toolbar ×12
android ×11
android-collapsingtoolbarlayout ×2
c# ×1
textview ×1
xamarin ×1