下面我在主题中添加了EditText样式.我添加了宽度和高度alos.所以我从我的edittext视图中删除了android:layout_width和android:layout_height.但这是错误的说法.如果我添加宽度和高度它工作正常.有什么不同.主题不适用于我的edittext视图吗?
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:editTextStyle">@style/custom_EditTextStyle</item>
</style>
<style name="custom_EditTextStyle" parent="@android:style/Widget.EditText">
<item name="android:background">@drawable/edittextbox</item>
<item name="android:singleLine">true</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">48dp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我的editText视图
<EditText android:hint="Username" />
Run Code Online (Sandbox Code Playgroud) 我用ActionBarSherlock创建了一个操作栏.我想设置操作栏的样式,这样当我按下menuitem(从溢出中弹出的下拉项目)时,menuitem背景应该会改变颜色.(现在它改为默认的全息蓝色,我希望它是另一种颜色).
经过长时间的googleing和测试,我想到了这个:
themes.xml:
<style name="AppTheme" parent="Holo.Theme">
<item name="android:popupMenuStyle">@style/PopupMenuStyle</item>
<item name="popupMenuStyle">@style/PopupMenuStyle</item>
</style>
<style name="PopupMenuStyle" parent="@style/Widget.Sherlock.PopupMenu">
<item name="android:dropDownSelector">@drawable/menu_selector</item>
</style>
Run Code Online (Sandbox Code Playgroud)
menu_selector.xml:(喜欢abs__list_selector_holo_dark.xml)
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:drawable="@android:color/transparent" />
<item android:state_focused="true" android:state_enabled="false" android:state_pressed="true" android:drawable="@drawable/abs__list_selector_disabled_holo_dark" />
<item android:state_focused="true" android:state_enabled="false" android:drawable="@drawable/abs__list_selector_disabled_holo_dark" />
<item android:state_focused="true" android:state_pressed="true" android:drawable="@color/AppRed" />
<item android:state_focused="false" android:state_pressed="true" android:drawable="@color/AppRed" />
<item android:state_focused="true" android:drawable="@drawable/abs__list_focused_holo" />
<item android:drawable="@color/AppRed" />
</selector>
Run Code Online (Sandbox Code Playgroud)
不幸的是,背景仍然变为蓝色而不是红色.我在这里失踪了什么?
我有一个用这个生成器创建的自定义主题.它有一个我不喜欢的Spinners的自定义样式.我想改变背景drawable,但我似乎无法弄清楚哪个属性控制它.
这就是主题版本的样子

这是使用Holo.Light主题时的样子.

请注意第一个(主题)图像中下拉列表周围的深灰色线条.这就是我想要摆脱的.什么财产控制这个?我希望它们与默认值匹配.
什么控制下拉列表的垂直对齐?如您所见,它与第一张图像中的微调器重叠(它下面的线不可见,因为它在第二张图像中).
android android-layout android-theme android-spinner android-styles
目前在Android 4.3设备上.我正在使用这里提供的优秀答案我能够减少AlertDialog单个项目的字体大小:
<style name="AlertDialogTheme" parent="android:Theme.Dialog">
<item name="android:textSize">13sp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
对话框本身构建为:
ContextThemeWrapper cw = new ContextThemeWrapper( this, R.style.AlertDialogTheme );
AlertDialog.Builder builder = new AlertDialog.Builder(cw);
Run Code Online (Sandbox Code Playgroud)
但是,问题是项目的个别高度仍然保持不变 - 实际上,当您在对话框中滚动时,会显示第五个元素:

我尝试设置dividerHeight但只是增加了间距.我也把layout_margin财产设置为0dp没有成功.
此对话框的正确样式定义是什么,以减少标签之间的空间?
请注意,我不想再使用视图构建整个对话框.我想保留现有的AlertDialog.
我有一个用作按钮的图像.它是RelativeLayout中的ImageView.RelativeLayout是接收触摸事件的视图.触摸时,我想将图像部分灰化为反馈.我该怎么做呢?
我能想到的最好的方法是在ImageView上放置另一个带有黑色背景的View,并将其设置为100%透明,但触摸时只有50%透明.有没有办法直接设置RelativeLayout或ImageView的样式而不使用额外的View?
提前致谢...
所以我想改变我的alertdialogs强调颜色,我把它添加到我的styles.xml中
<style name="AppTheme.AlertDialogTheme" parent="Theme.AppCompat.Light.Dialog">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
Run Code Online (Sandbox Code Playgroud)
这进入我的基本风格:
<item name="android:alertDialogTheme">@style/AppTheme.AlertDialogTheme</item>
Run Code Online (Sandbox Code Playgroud)
颜色改变了,很酷,但现在我的所有对话框都变小了.如何在更改颜色时保留尺寸?
我已经设置样式为我CardView的style.xml文件,但它给我的错误在编译时app:cardCornerRadius,app:cardElevation,应用:cardPreventCornerOverlap和app:contentPadding属性.CardView在Android中设置样式的正确方法是什么?
以下是我的一些代码:
<style name="CardViewStyle" parent="CardView">
<item name="android:layout_marginBottom">@dimen/cardMarginVertical</item>
<item name="android:layout_marginTop">@dimen/cardMarginVertical</item>
<item name="android:layout_marginLeft">@dimen/cardMarginHorizontal</item>
<item name="android:layout_marginRight">@dimen/cardMarginHorizontal</item>
<item name="app:cardCornerRadius">2dp</item>
<item name="app:cardElevation">2dp</item>
<item name="app:cardPreventCornerOverlap">false</item>
<item name="app:contentPadding">0dp</item>
<item name="android:layout_width">match_parent</item>
</style>
Run Code Online (Sandbox Code Playgroud) 我想在一个主题中应用自定义样式TextInputLayout's hint并将error其全局应用,即在styles.xml中定义它,并以某种方式将其TextInputLayouts应用于整个应用程序中使用的所有内容,而无需像这样添加内联:
<android.support.design.widget.TextInputLayout
android:id="@+id/usernameWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/email_username"
android:textColorHint="@color/grey_text"
app:theme="@style/my_custom_style">
<style name="my_custom_style" parent="Widget.Design.TextInputLayout">
<item name="android:textColorHint">@color/success_accent</item>
<item name="android:textSize">20sp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我们可以像这样做Button小部件:
styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="buttonStyle">@style/my.Widget.Button</item>
<item name="android:buttonStyle">@style/my.Widget.Button</item>
</style>
<style name="my.Widget.Button" parent="@android:style/Widget.TextView">
<item name="android:gravity">center</item>
<item name="android:textSize">@dimen/some_dimen</item>
<item name="android:textAllCaps">false</item>
</style>
Run Code Online (Sandbox Code Playgroud)
注意:我目前正在考虑将子类化TextInputLayout作为最后的手段,因此,请在回答时牢记这一点.
谢谢 :)
我想删除工具栏中内置后箭头和imageview之间的空格.
下面是我的xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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"
tools:context=".activities.AppBaseActivity">
<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
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/colorPrimary"
android:contentInsetStart="0dp"
android:contentInsetLeft="0dp"
android:contentInsetRight="0dp"
android:contentInsetEnd="0dp"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:contentInsetRight="0dp"
app:contentInsetEnd="0dp"
app:popupTheme="@style/AppTheme.PopupOverlay">
<RelativeLayout
android:id="@+id/rl_User_Profile"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imageView_User_Image"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_margin="1dp"
android:src="@drawable/app_logo" />
<itcube.spcl.mobileapp.ui.view.CustomTextView
app:font="droid-serif.regular.ttf"
android:id="@+id/textView_User_Name"
android:text="jkdfsbjkbdkjsbf"
android:layout_marginLeft="3dp"
android:layout_toRightOf="@+id/imageView_User_Image"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignTop="@+id/imageView_User_Image"/>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_app_base" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
样式xml
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
Run Code Online (Sandbox Code Playgroud)
PSA快照显示我必须删除的空间.Java文件只是有代码来定义工具栏和设置主页按钮启用意味着后退箭头.
android android-styles android-toolbar android-coordinatorlayout android-appbarlayout
我正在尝试摆脱android.enableAapt2=false我们项目中即将被删除的选项。一直很痛苦,但我希望我能到达那里。
现在我被困住了BuildException: Failed to process resources, see aapt output above for details。
问题似乎是这样的:
error: style attribute '@android:attr/textColor' not found.
Message{kind=ERROR, text=error: style attribute '@android:attr/textColor' not found.,
sources=[/Users/<username>/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/4215c9c9bb2efc5bb086ff343ac44128/res/values/values.xml],
original message=, tool name=Optional.of(AAPT)}
Run Code Online (Sandbox Code Playgroud)
我找到了以下问题和答案,但是我相信它不在我们自己的项目中时会有所不同:无法完成Gradle Build,链接引用失败
发生这种情况的原因是什么,我该如何解决?
规格:
Android Studio 3.1.2
JRE:1.8.0_152-release-1024-b01 x86_64
buildTools版本:27.0.3
Gradle:4.6
Gradle插件:3.1.2
编辑:
万一我删除从我们的项目样式和属性的每一行,做一个干净的构建和缓存和重新启动,一切都无效,但在构建仍然指向其手指values.xml的com.android.support:appcompat-v7:27.1.1。
android android-appcompat android-styles android-gradle-plugin