我有一个 fragment 的 Activity 。从这个 fragment 我调用方法来显示上下文操作栏,这是我的问题。
样式:
<style name="MyThemeLight" parent="@android:style/Theme.Holo.Light.NoActionBar">
<item name="android:actionModeCloseButtonStyle">@style/MyCloseButton</item>
<item name="android:actionModeStyle">@style/ContextualBar.Light</item>
<item name="android:actionOverflowButtonStyle">@style/OverFlow</item>
<item name="android:actionBarStyle">@style/MyMainActionBar</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:actionModeCloseDrawable">@drawable/close_white</item>
<item name="android:windowActionModeOverlay">true</item>
<item name="android:windowBackground">@color/background</item>
<item name="android:dropDownListViewStyle">@style/PopupMenuLight</item>
</style>
<style name="MyMainActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">@drawable/ab_bottom_solid_dark_holo</item>
<item name="android:height">1dp</item> </style>
<style name="ContextualBar.Light" parent="android:style/Widget.Holo.ActionMode">
<item name="android:background">@drawable/ab_bottom_solid_dark_holo</item>
<item name="android:height">56dp</item> </style>
<style name="OverFlow" parent="@android:style/Widget.Holo.ActionButton.Overflow">
<item name="android:src">@drawable/menu_white</item> </style>
<style name="MyCloseButton" parent="android:style/Widget.ActionButton.CloseMode">
<item name="android:textColor">#000000</item> </style>
</resources>
布局:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layoutright"
android:layout_width="fill_parent"
android:layout_height="match_parent">
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layoutleft"
android:layout_width="fill_parent"
android:layout_height="match_parent">
<!-- The main content view -->
<android.support.v4.view.ViewPager
android:id="@+android:id/viewpager"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<!-- The navigation drawer -->
<fragment
class="...BookmarksLeft"
android:id="@+id/drawer_listleft"
android:layout_width="306dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:tag="bookleft"/>
</android.support.v4.widget.DrawerLayout>
<fragment
class="...BookmarksRight"
android:layout_width="306dp"
android:layout_height="match_parent"
android:layout_gravity="end"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:tag="bookright"/>
</android.support.v4.widget.DrawerLayout>
</FrameLayout>
如您所见,主样式没有操作栏,状态栏是透明的,“android:windowActionModeOverlay”为真,“android:fitsSystemWindows”为真,但我得到:
有什么办法可以让CAB下移吗?
最佳答案
只需更改 paddingTop 和高度。 然后在 AppTheme 中添加你的 actionMode 样式。
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="actionModeStyle">@style/CustomActionMode</item>
</style>
<style name="CustomActionMode" parent="@style/Widget.AppCompat.Light.ActionMode.Inverse">
<item name="android:paddingTop">25dp</item>
<item name="height">80dp</item>
<item name="titleTextStyle">@style/Title</item>
</style>
关于android - 透明状态栏覆盖 Kitkat 上的操作模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26318057/
我需要在客户计算机上运行Ruby应用程序。通常需要几天才能完成(复制大备份文件)。问题是如果启用sleep,它会中断应用程序。否则,计算机将持续运行数周,直到我下次访问为止。有什么方法可以防止执行期间休眠并让Windows在执行后休眠吗?欢迎任何疯狂的想法;-) 最佳答案 Here建议使用SetThreadExecutionStateWinAPI函数,使应用程序能够通知系统它正在使用中,从而防止系统在应用程序运行时进入休眠状态或关闭显示。像这样的东西:require'Win32API'ES_AWAYMODE_REQUIRED=0x0
我有一个模型:classItem项目有一个属性“商店”基于存储的值,我希望Item对象对特定方法具有不同的行为。Rails中是否有针对此的通用设计模式?如果方法中没有大的if-else语句,这是如何干净利落地完成的? 最佳答案 通常通过Single-TableInheritance. 关于ruby-on-rails-Rails-子类化模型的设计模式是什么?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.co
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
我有一个包含模块的模型。我想在模块中覆盖模型的访问器方法。例如:classBlah这显然行不通。有什么想法可以实现吗? 最佳答案 您的代码看起来是正确的。我们正在毫无困难地使用这个确切的模式。如果我没记错的话,Rails使用#method_missing作为属性setter,因此您的模块将优先,阻止ActiveRecord的setter。如果您正在使用ActiveSupport::Concern(参见thisblogpost),那么您的实例方法需要进入一个特殊的模块:classBlah
鉴于我有以下迁移:Sequel.migrationdoupdoalter_table:usersdoadd_column:is_admin,:default=>falseend#SequelrunsaDESCRIBEtablestatement,whenthemodelisloaded.#Atthispoint,itdoesnotknowthatusershaveais_adminflag.#Soitfails.@user=User.find(:email=>"admin@fancy-startup.example")@user.is_admin=true@user.save!ende
我想设置一个默认日期,例如实际日期,我该如何设置?还有如何在组合框中设置默认值顺便问一下,date_field_tag和date_field之间有什么区别? 最佳答案 试试这个:将默认日期作为第二个参数传递。youcorrectlysetthedefaultvalueofcomboboxasshowninyourquestion. 关于ruby-on-rails-date_field_tag,如何设置默认日期?[rails上的ruby],我们在StackOverflow上找到一个类似的问
当我的预订模型通过rake任务在状态机上转换时,我试图找出如何跳过对ActiveRecord对象的特定实例的验证。我想在reservation.close时跳过所有验证!叫做。希望调用reservation.close!(:validate=>false)之类的东西。仅供引用,我们正在使用https://github.com/pluginaweek/state_machine用于状态机。这是我的预订模型的示例。classReservation["requested","negotiating","approved"])}state_machine:initial=>'requested
我将我的Rails应用程序部署到OpenShift,它运行良好,但我无法在生产服务器上运行“Rails控制台”。它给了我这个错误。我该如何解决这个问题?我尝试更新rubygems,但它也给出了权限被拒绝的错误,我也无法做到。railsc错误:Warning:You'reusingRubygems1.8.24withSpring.UpgradetoatleastRubygems2.1.0andrun`gempristine--all`forbetterstartupperformance./opt/rh/ruby193/root/usr/share/rubygems/rubygems
我在pry中定义了一个函数:to_s,但我无法调用它。这个方法去哪里了,怎么调用?pry(main)>defto_spry(main)*'hello'pry(main)*endpry(main)>to_s=>"main"我的ruby版本是2.1.2看了一些答案和搜索后,我认为我得到了正确的答案:这个方法用在什么地方?在irb或pry中定义方法时,会转到Object.instance_methods[1]pry(main)>defto_s[1]pry(main)*'hello'[1]pry(main)*end=>:to_s[2]pry(main)>defhello[2]pry(main)
我正在尝试从Postgresql表(table1)中获取数据,该表由另一个相关表(property)的字段(table2)过滤。在纯SQL中,我会这样编写查询:SELECT*FROMtable1JOINtable2USING(table2_id)WHEREtable2.propertyLIKE'query%'这工作正常:scope:my_scope,->(query){includes(:table2).where("table2.property":query)}但我真正需要的是使用LIKE运算符进行过滤,而不是严格相等。然而,这是行不通的:scope:my_scope,->(que