如何更改TabBar的背景颜色而不更改flutter中的AppBar?TabBar没有BG proprety,有解决方法吗?
我正在尝试使用本教程实现带有图像模式的灵活空间.
一切正常.
注意AppBarLayout的高度定义是192dp.
我想改变屏幕的高度1/3,以匹配此模式的谷歌示例.
这是活动的onCreate中的代码(布局xml与教程中的完全相同):
AppBarLayout appbar = (AppBarLayout)findViewById(R.id.appbar);
float density = getResources().getDisplayMetrics().density;
float heightDp = getResources().getDisplayMetrics().heightPixels / density;
appbar.setLayoutParams(new CoordinatorLayout.LayoutParams(LayoutParams.MATCH_PARENT, Math.round(heightDp / 3)));
Run Code Online (Sandbox Code Playgroud)
但由于某种原因,结果并不是我所期待的.我根本无法使用此代码查看应用栏.(没有代码,高度显示为预期,但它来自XML,无法动态设置).
我已经制作了像这样的对齐应用栏:
请注意,当滚动条保留在中间时(即标题是一半可见,则应用栏会自动捕捉)
在谷歌播放的情况下,这是按钮的样子:
现在,我想让快照像谷歌播放中的那样工作.这是在发生快照时,只有应用栏应该捕捉并且回收者视图不应该移动.如果该解决方案也支持前棒棒糖设备会更好.
谢谢!
我发现很难在Material UI上创建带有菜单的导航栏.我已经阅读了它的AppBar文档.但是,似乎他们没有提供这个功能.
1)Material UI AppBar
2)React Bootstrap Navbar
如何像React Bootstrap一样在Material UI上创建导航栏菜单呢?
当我点击底部应用栏中的图标时,它会保持打开状态.我点击按钮时需要关闭它.我怎样才能做到这一点?
我正在使用C#,XAML.
我正在开发一个Windows 8应用程序项目.我正在使用Visual Studio 2012和它的预定义模板(GroupedPage,SplitPage,ItemsPage).
这时我需要添加一个App栏.我选择的方式是创建一个并在所有页面上显示它.我读这篇文章:http://msdn.microsoft.com/en-us/library/windows/apps/xaml/jj150604.aspx
要在我的项目中包含它,我将全局页面设置为App.xaml上的起始页面
protected async override void OnLaunched(LaunchActivatedEventArgs args)
...
if (!rootFrame.Navigate(typeof(GlobalPage), args.Arguments))
throw new Exception("Failed to create initial page");
...
Run Code Online (Sandbox Code Playgroud)
在Global页面上,我正在更改OnLaunched方法,以便进入真正的主页面:
rootPage = e.Parameter as Page;
frame1.Navigate(typeof(MainPage), this);
Run Code Online (Sandbox Code Playgroud)
我为按钮添加了事件订阅,例如
private void ButtonBlogList_Click(object sender, RoutedEventArgs e)
{
this.Frame.Navigate(typeof(BlogListManagement), this);
}
Run Code Online (Sandbox Code Playgroud)
启动应用程序后,将显示应用程序栏,我可以使用内部的应用程序按钮进行导航,但在第一次导航后,AppBar不会显示在目标页面上.
知道我的错误吗?
谢谢你的帮助.
在我的Windows Phone应用程序的示例appbar中,我可以看到这行代码添加了一个按钮:
ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
Run Code Online (Sandbox Code Playgroud)
我觉得有趣的是图标来自"/ Assets/AppBar /".那里是否有任何其他标准Windows Phone appbar图标,如果有的话,我可以使用某个列表或参考吗?
我正在尝试使用带有appbar布局的协调器布局,该布局将片段作为"滚动视图".该片段由一个recyclerView和一个底部对齐的布局组成,按住一个按钮,如下所示:
但是,默认情况下隐藏底部:
并且仅在我滚动后显示.
从我的活动课:
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TestFragment fragment = (TestFragment) getFragmentManager().findFragmentByTag("Test");
if (fragment == null)
fragment = new TestFragment();
getFragmentManager().popBackStack();
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment, "Test");
fragmentTransaction.commit();
}
Run Code Online (Sandbox Code Playgroud)
活动布局:
<RelativeLayout 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.CoordinatorLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
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/tabs"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="enterAlways|scroll"
app:tabGravity="fill"
app:tabMode="fixed"/>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
片段布局:
<RelativeLayout 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.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/bottomView"
android:scrollbars="vertical"
android:visibility="visible"/>
<RelativeLayout …Run Code Online (Sandbox Code Playgroud) android appbar android-fragments coordinator-layout android-coordinatorlayout
这个问题被张贴在这里,因为这里关于堆栈溢出的相关问题只有解决方法,但没有直截了当的方法。