草庐IT

android - 在 xml 中设置 Toolbar 一半的 attr/actionBarSize 高度

有没有在布局xml文件中设置“android.support.v7.widget.Toolbar”一半的预定义属性(如“?android:attr/actionBarSize”)的高度?事实上,我希望我的工具栏的高度是这样的: 最佳答案 无法在xml中执行算术操作。如果你想通过xml给值,那么你必须执行以下操作:在values/dimes.xml中定义一个变量halfActionBar并设置为28dp(原来是56dp)。在values-land/dimes.xml中定义一个变量halfActionBar并设置为24dp(原来是48d

android - 如何使样式 ="?attr/actionButtonStyle"可用于矩形工具栏按钮

在我们之前的全息设计应用程序(targetSdkVersion21,主题为Theme.Sherlock.Light.DarkActionBar)中,我们使用系统样式属性attr/actionButtonStyle定义我们的自定义操作栏按钮样式。actionbar_custom_view_done_discard.xmlactionbar_done_button.xmlStockAlertFragmentActivity.javapublicclassStockAlertFragmentActivityextendsSherlockFragmentActivity{@Overridepu

android - react native 中的 "resource android:attr/fontVariationSettings not found."

我有一个react-native项目,它昨天在android上工作正常,但是今天当我运行react-nativerun-android时发生错误。今天在android上运行之前,没有任何改变,只是在AndroidStudio中打开它。报错如下:.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/d1dde4fd0fa50f7f7336597688c557a9/res/values/values.xml:252:5-69:AAPT:error:resourceandroid:attr/fontVariationSet

android - 无法通过 ?attr 设置标题首选项图标

我已经创建了preference-headers.xml。我想通过?attr设置标题图标,但它不显示图标。 最佳答案 我通过混合使用headers.xml和更改图标解决了这个问题。publicvoidonBuildHeaders(Listtarget){this.loadHeadersFromResource(R.xml.pref_headers,target);//searchforthecurrentheaderbycomparingthetitelResIdsfor(Headerheader:target){if(header

android - 我怎样才能找到 ?android :attr/dividerVertical? 的定义

我想查看垂直分隔符的定义,我不确定属性的确切含义,但是当单击intellij中的属性定义时,我将转到attrs.xml并显示以下内容,这没有帮助。我的具体问题是我正在尝试使用dividerVertical样式实现带有插入列表分隔符的列表。为此,我定义了自己的插图形状。这不起作用,因为android不接受“?android:attr/dividerVertical”作为颜色。它无论如何都行不通,因为垂直分隔线有一个alpha分量,所以我需要知道什么颜色和不透明度是垂直分隔线?但理想情况下,我想知道如何检查android中任何资源组件的来源,这样我就再也不会遇到这个问题。谢谢码头

android - 错误 : Error: No resource found that matches the given name: attr 'colorAccent'

我正在学习MaterialDesign,特别是我想使用MaterialDesign自定义我的应用程序,也适用于较旧的Android版本。我正在阅读本指南:https://developer.android.com/training/material/compatibility.html#SupportLib关于调色板,指南说:ToobtainmaterialdesignstylesandcustomizethecolorpalettewiththeAndroidv7SupportLibrary,applyoneoftheTheme.AppCompatthemes:@color/mate

android - 什么样式/attr/drawable 用于反背景?

我尝试制作一个ExpandableListView,其中组标题是反向绘制的。通过XML更改文本颜色、大小等没有问题。我什至发现了如何使用像这样的系统默认设置但是对于背景颜色?!我不明白为什么这些样式不包含背景颜色信息?!当然我可以使用直接颜色,但我寻找好的默认背景属性或样式。像“风格/背景.For.TextAppearance.Medium.Inverse”;-)什么是好的解决方案?因此,对于深色主题设备,我得到白色/灰色,而对于白色主题,我得到黑色?或者我应该只使用R.color.background_light吗?你好,乔格PS:这里的第一个问题;-)感谢过去几个月和几年在这里回答

android - 找不到与给定名称 : attr 'android:actionModeShareDrawable' appcompat-v7:21. 0.0 与 compileSdkVersion 21 匹配的资源

我正在尝试在我的一个项目中使用MaterialDesign。但是我对appcompat-v7:21.0.0库的体验非常糟糕。在AndroidStudio中添加依赖项并开始同步后,我收到以下错误。Error:Noresourcefoundthatmatchesthegivenname:attr'android:actionModeShareDrawable'.Noresourcefoundthatmatchesthegivenname:attr'android:overlapAnchor'.但我确信我正在使用最新的构建工具针对最新的SDK21进行编译。这是我的构建配置。android{c

android - 将 <include> 标签与 ?attr/myAttr 一起使用

我正在尝试根据父Theme在我的View中包含不同的布局。按照思路:attrs.xmlstyles.xml@layout/layout_a@layout/layout_bactivity.xml当我运行上面的代码时,我会得到以下异常:java.lang.RuntimeException:UnabletostartactivityComponentInfo{com.my.package/com.my.package.MainActivity}:android.view.InflateException:Youmustspecifiyavalidlayoutreference.Thelay

java - 如何以编程方式设置android :background ="?android:attr/selectableItemBackground"?

如何以编程方式android:background="?android:attr/selectableItemBackground""?我尝试了mView.setBackgroundResource(android.R.attr.selectableItemBackground);但它没有用。 最佳答案 您需要先解析属性。TypedValuetypedValue=newTypedValue();//IusedgetActivity()asifyouwerecallingfromafragment.//Youjustwanttocal