我使用波纹管样式将对话框背景颜色更改为深色,在我使用的首选项页面中ListPreference,应用此样式后,cancelListPreference 的按钮在对话框背景中消失了。
<style name="AppThemeBase" parent="Theme.MaterialComponents.DayNight">
<item name="colorPrimary">#212D3B</item>
<item name="colorPrimaryDark">#172331</item>
<item name="colorAccent">#61A3D7</item>
<item name="android:textColorPrimary">#FFFFFF</item>
<item name="android:dialogTheme">@style/AppTheme.Dialog</item>
<item name="android:alertDialogTheme">@style/AppTheme.Dialog</item>
</style>
<style name="AppTheme.Dialog" parent="Theme.MaterialComponents.DayNight.Dialog">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:background">#212D3B</item>
<item name="colorPrimary">#61A3D7</item>
<item name="colorPrimaryDark">#8DB2D3</item>
<item name="colorAccent">#61A3D7</item>
</style>
Run Code Online (Sandbox Code Playgroud)
有没有办法改变这个按钮的颜色?
android listpreference android-styles material-components-android
我想简单地将样式应用到这样的主题级别上的所有按钮
<style name="BaseTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
...
<item name="buttonStyle">@style/DefaultButton</item>
</style>
<style name="DefaultButton" parent="Widget.MaterialComponents.Button">
<item name="android:textColor">@color/whatever</item>
</style>
<Button
android:id="@+id/addChannelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:layout_margin="16dp"
android:text="Add room" />
Run Code Online (Sandbox Code Playgroud)
为什么这不起作用?它会在 appcompat
// 如果我使用Theme.MaterialComponents.Light.NoActionBar.Bridge,那么它有效
android android-button material-design material-components material-components-android
我有一个错误'Theme.MaterialComponents.Light.NoActionBar'的styles.xml(在'Theme.MaterialComponents.Light.NoActionBar'经过多次gradle这个更新是因为错误的红色)。我的组件也没有按照我的设计思路很好地排列。
我已经清理并重建项目,使缓存无效/重新启动,更新 gradle(可能不是正确答案)并且没有答案。我只是想也许我是唯一一个遇到这个问题的人,也许是因为我的初级问题:')
样式文件
`
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/hitam</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
Run Code Online (Sandbox Code Playgroud)
`
项目梯度
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Run Code Online (Sandbox Code Playgroud)
'
应用程序渐变
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
defaultConfig {
applicationId "blablabla" …Run Code Online (Sandbox Code Playgroud) java android material-components material-components-android androidx
我试图让AutoCompleteTextView这个图像看起来像https://ibb.co/ZJxmgK5,但无法做到这一点。轮廓框在结果中不可见
下面是我目前的代码。早些时候我尝试添加一个EditText,TextInputLayout但现在我想在这个中添加自动完成。
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/input_layout_holiday_destination"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/lbl_destination_big">
<AutoCompleteTextView
android:id="@+id/edittext_holiday_destination"
style="@style/Base.Widget.AppCompat.EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="10"
android:background="@android:color/transparent"
android:hint="@string/lbl_destination"
android:layout_marginLeft="@dimen/margin8"
android:singleLine="true"
android:lines="1"
android:textSize="25sp"
android:nextFocusDown="@+id/txv_holiday_num_of_nights"
android:imeOptions="actionNext"
android:textCursorDrawable="@drawable/edittext_cursor_drawable"/>
/>
</com.google.android.material.textfield.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
预期的结果是上面给出了 URL 的图像。
android autocompletetextview material-design android-textinputlayout material-components-android
使用Material Design 库中的TextInputLayout,我们可以使用各种结束图标模式进行密码编辑、文本清除和自定义模式。此外,如果我们使用任何样式,它将自动应用显示打开和关闭 V 形的特殊结束图标模式。Widget.MaterialComponents.TextInputLayout.*.ExposedDropdownMenu
各种图标模式示例:
鉴于结束图标的各种用例,我们决定在 中使用加载指示器InputTextLayout,使其看起来像这样:
应该如何着手实施呢?
android loading android-progressbar progress-bar material-components-android
我正在尝试使用可能在 stackoverflow 中为此问题定义的所有解决方案来更改 AlertDialog 的颜色,但它仍然不起作用。
这是我用来尝试实现的代码:
val vacationDialog = AlertDialog.Builder(fragment.context,R.style.DialogTheme)
val factory = LayoutInflater.from(OtrosDetailFragment.fragment.context);
var view = factory.inflate(R.layout.sample, null)
[...]
vacationDialog.setView(view)
val window = vacationDialog.create()
vacationDialog.setPositiveButton("Cerrar"){dialog, which ->
dialog.dismiss()
}
/**Listener called when the AlertDialog is shown**/
vacationDialog.show()
window.setOnShowListener {
/**Get the positive button from the AlertDialog**/
val positiveButton = window.getButton(DialogInterface.BUTTON_POSITIVE)
/**Set your color to the positive button**/
positiveButton.setBackgroundColor(ContextCompat.getColor(fragment.context!!, R.color.colorPrimary))
positiveButton.setTextColor(ContextCompat.getColor(fragment.context!!, R.color.colorPrimary))
positiveButton.setHintTextColor(ContextCompat.getColor(fragment.context!!, R.color.colorPrimary))
positiveButton.setLinkTextColor(ContextCompat.getColor(fragment.context!!, R.color.colorPrimary))
}
Run Code Online (Sandbox Code Playgroud)
这是styles.xml 中定义的DialogTheme 样式,顺便说一下,我找不到更改默认按钮颜色(黑色)的方法,并且似乎覆盖了从代码中尝试的任何更改。
<style name="DialogTheme" parent="android:Theme.Holo">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<!-- No backgrounds, …Run Code Online (Sandbox Code Playgroud) android android-appcompat android-alertdialog material-design material-components-android
我正在制作一个聊天应用程序,我想在 editText 中放置一个按钮以启用媒体文件的发送。我不知道该怎么做。
试图使 editText 中的矢量资产可点击,但它不会
java android material-design material-components material-components-android
令我惊讶的是,如果 Snackbar 跨越多行,它本身似乎会在 TextView 上设置额外的填充。它有效地将 Snackbar 的高度加倍,并且由于某种原因只影响垂直填充。我在SnackbarContentLayout.onMeasure:
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (mMaxWidth > 0 && getMeasuredWidth() > mMaxWidth) {
widthMeasureSpec = MeasureSpec.makeMeasureSpec(mMaxWidth, MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
final int multiLineVPadding = getResources().getDimensionPixelSize(
R.dimen.design_snackbar_padding_vertical_2lines);
final int singleLineVPadding = getResources().getDimensionPixelSize(
R.dimen.design_snackbar_padding_vertical);
final boolean isMultiLine = mMessageView.getLayout().getLineCount() > 1;
boolean remeasure = false;
if (isMultiLine && mMaxInlineActionWidth > 0
&& mActionView.getMeasuredWidth() > mMaxInlineActionWidth) {
if (updateViewsWithinLayout(VERTICAL, multiLineVPadding,
multiLineVPadding - singleLineVPadding)) {
remeasure = true;
}
} else {
final int messagePadding = isMultiLine …Run Code Online (Sandbox Code Playgroud) android snackbar android-snackbar material-components material-components-android
我正在尝试为我的应用程序制作一些 Seekbar 作为距离值。我喜欢它看起来像这样(图片取自 -链接):
有人可以举一个简单的例子来说明如何制作这样的东西吗?
我知道我可以使用来自 Github 的“已经制作的”Seekbars,但我试图理解这个概念,以便我可以进一步设计它。
谢谢
android android-seekbar material-components material-components-android android-slider
安卓工作室 3.6
在我的风格。xml
<style name="buttonStyle">
<item name="android:textColor">@color/default_button_textColor</item>
<item name="android:backgroundTint">@color/button_bg_color</item>
<item name="android:textSize">18sp</item>
<item name="android:textAllCaps">true</item>
</style>
<style name="buttonClickStyle">
<item name="android:textColor">@color/button_bg_color</item>
<item name="android:backgroundTint">@color/button_click_bg_color</item>
<item name="android:textSize">18sp</item>
<item name="android:textAllCaps">true</item>
</style>
Run Code Online (Sandbox Code Playgroud)
在 xml 布局中:
<com.google.android.material.button.MaterialButton
android:id="@+id/buttonStartSearchBluetooth"
style="@style/buttonStyle"
android:layout_width="0dp"
android:layout_height="@dimen/button_height"
android:layout_margin="@dimen/button_margin"
android:onClick="onClickButtonStartSearch"
android:text="@string/start_search"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
Run Code Online (Sandbox Code Playgroud)
当单击按钮时,我尝试像这样更改样式:
dataBinding.buttonStartSearchBluetooth.setTextAppearance(R.style.buttonClickStyle)
Run Code Online (Sandbox Code Playgroud)
但它只改变文本颜色。没变backgroundTint
为什么?
android android-button android-styles material-components material-components-android
android ×10
material-components-android ×10
java ×2
androidx ×1
loading ×1
progress-bar ×1
snackbar ×1