是MDC排版特有的Roboto字体,或者我们可以与其他谷歌的字体,如果这样实施,简直到应用建议的方式font-familyCSS来body?
最后,似乎所有头元素联系在一起的<h1>元素,这似乎打破HTML5的语义性质,即h1通常具有高于意义h5。
我是 android material-components 的新手,我第一次尝试了带有 FilledBox 样式的基本 TextInputLayout,默认情况下背景看起来像半透明,根据我们的设计,我需要将其更改为纯白色。但是我试过app:boxBackgroundColor="#ffffff",然后文字和文字提示就看不见了!然后我尝试了 app:boxBackgroundColor="#80ffffff" 我可以看到它们是某种透明的。你知道为什么?我只想要纯白色的背景,其他的保持不变。
提前致谢!
<com.google.android.material.textfield.TextInputLayout
style=".MaterialComponents.TextInputLayout.FilledBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="120dp"
app:boxBackgroundColor="#ffffff">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#ff000000"
android:textColorHint="#ff0000"
android:hint="Location"/>
</com.google.android.material.textfield.TextInputLayout>
Run Code Online (Sandbox Code Playgroud) 我需要在 MDC 卡的标题之前添加一个图标,如图所示(标签 2)。但是,根据 MDC 设计,我不知道正确的 HTML。这是我迄今为止的卡片 HTML 代码:
<div class="mdc-card demo-card undefined">
<div class="demo-card__primary">
<h1 class="demo-card__title mdc-typography--headline6">Some Title</h1>
<div class="mdc-card__actions">
<div class="mdc-card__action-buttons">
<button class="mdc-button mdc-card__action mdc-card__action--button mdc-button--raised mdc-ripple-upgraded">
Button 1
</button>
<button class="mdc-button mdc-card__action mdc-card__action--button mdc-button--raised mdc-ripple-upgraded">
Button 2
</button>
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
有人可以指出我要添加的正确 HTML 吗?MDC 文档不是很清楚。
html material-design material-components mdc-components material-components-web
我的主要应用主题父主题是 MaterialComponents 主题。我更改了颜色,但材质组件(MaterialButton、InputLayout、EditText)没有使用我的强调色(它们使用了一些蓝色,我声明的强调色是蓝绿色)有什么问题?处理主题化材质组件的最佳方法是什么?
我的主题:
<style name="AppTheme" parent="Theme.MaterialComponents">
<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)
编辑:将主题更改为 Theme.MaterialComponents.Bridge 并不能解决该问题。
我有这个代码
this.mdc_text = mdc.textField.MDCTextField.attachTo(this.$el);
if (this.autofocus) {
this.mdc_text.activateFocus();
}
Run Code Online (Sandbox Code Playgroud)
但函数 activateFocus 未定义。我怎样才能集中注意力?
https://material.io/develop/web/components/input-controls/text-field/
谢谢
javascript material-design material-components material-components-web
我在我的应用程序中使用 iOS Material 组件,我在这里遇到了选项卡。实现它很容易,在我做了一些小改动以匹配我的设计后,结果就是我想要的:
我使用以下代码实现了这一点:
func setupTabBar() {
let customTabBar = MDCTabBar(frame: view.bounds)
customTabBar.items = [
UITabBarItem(title: "Cards", image: nil, tag: 0),
UITabBarItem(title: "Mobile", image: nil, tag: 0)
]
customTabBar.itemAppearance = .titledImages
customTabBar.alignment = .justified
customTabBar.itemAppearance = .titles
//colors
customTabBar.tintColor = #colorLiteral(red: 0.8039215803, green: 0.8039215803, blue: 0.8039215803, alpha: 1)
customTabBar.selectedItemTintColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
customTabBar.unselectedItemTintColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
customTabBar.barTintColor = UIColor(red:0.00, green:0.33, blue:0.59, alpha:1.0)
tabBarContainerView.addSubview(customTabBar)
customTabBar.sizeToFit()
tabBarContainerView.layer.shadowOffset …Run Code Online (Sandbox Code Playgroud) 我想实现看起来像材料组件示例中的按钮形状

我已经尝试做的是为这样的按钮设置自定义样式
<style name="ButtonAddLeft" parent="Widget.MaterialComponents.Button.Icon">
<item name="backgroundTint">@color/secondary</item>
<item name="android:textColor">@color/primary</item>
<item name="shapeAppearance">@style/ButtonAddLeftShape</item>
</style>
<style name="ButtonAddLeftShape">
<item name="cornerFamilyTopLeft">cut</item>
<item name="cornerFamilyBottomLeft">cut</item>
<item name="cornerSize">12dp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
但这看起来不像示例中的那个,无论我如何设置cornerSize。
android android-button material-design material-components material-components-android
这是我应用程序的主要风格
<style name="Theme.RoundRobin" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorSecondaryVariant</item>
<item name="colorAccent">@color/colorPrimaryVariant</item>
<item name="colorControlActivated">@color/colorControlActivated</item>
<item name="colorControlNormal">@color/colorControlNormal</item>
<item name="colorControlHighlight">@color/colorControlNormal</item>
<item name="android:textColorPrimary">@color/textColorPrimary</item>
<item name="android:windowLightStatusBar" tools:targetApi="m">false</item>
</style>
Run Code Online (Sandbox Code Playgroud)
据我所知,colorControlHighlight 应该为 textinputlayout 中的下划线、标签和光标着色。
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/username_til"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginLeft="24dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="24dp"
android:layout_marginRight="24dp"
app:hintTextAppearance="@style/TextAppearance.Subtitle1"
app:layout_constraintBottom_toTopOf="@+id/password_til"
app:layout_constraintEnd_toEndOf="parent"
android:hint="Username"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/usernameEt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.Body2"/>
</com.google.android.material.textfield.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
没有一个 colorControls 应该与新的 MaterialCompoents 一起使用。
我在这里错过了什么吗
我给了我的 TextInput 这种样式,但它看起来好像 MaterialComponents 不能很好地与 colorControlsX 一起使用
<style name="Widget.RoundRobin.TextInputLayout.FilledBox" parent="Widget.MaterialComponents.TextInputLayout.FilledBox">
<item name="hintTextAppearance">@style/TextAppearance.Caption</item>
<item name="android:paddingBottom">8dp</item>
<item name="boxBackgroundColor">@color/colorWhite</item>
<item name="android:colorControlHighlight">@color/colorSecondaryVariant</item> // this doesn't …Run Code Online (Sandbox Code Playgroud) android material-design android-textinputlayout material-components material-components-android
最初,FAB(浮动操作按钮)只有一个形状:圆形,并且它只能选择在其中包含一个图标。
在过去一年左右的时间里,谷歌在其应用程序中添加了各种屏幕,显示改变其大小的 FAB。例如,如果你打开它的通讯录应用程序并选择一个联系人,那么你就是一个 FAB:
如果你滚动一点,它就会变成一个圆圈,里面只有一个图标:
我想知道如何制作这样的 FAB,并使用类似的,中间只有一个图标(没有文字),意思是圆角。
类似的东西:
起初,我试图只是将 FAB 的宽度设置得更大,但这并没有帮助,因为它坚持是一个完美的圆形(适合正方形,并且没有边缘)。
看到可能 FAB 目前无法处理这个,我改用 MaterialCardView:
<com.google.android.material.card.MaterialCardView
Run Code Online (Sandbox Code Playgroud)
android:layout_width="60dp" android:layout_height="32dp" android:clickable="true" android:focusable="true" app:cardBackgroundColor="..." app:cardCornerRadius="16dp">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" app:srcCompat="..."/>
</com.google.android.material.card.MaterialCardView>
Run Code Online (Sandbox Code Playgroud)
这有效,但点击效果消失了。
我也试过 MaterialButton,但这不支持中间的图标,只支持里面的各种文字。
后来,我注意到 FAB 实际上确实有一种方法可以自定义自身的形状:
另外,对于不断扩大的 FAB,我发现了这一点:
https://material.io/develop/android/components/extended-floating-action-button/
所以查看它的代码,我发现它使用了一个药丸的形状,我试图做一个与普通 FAB 类似的事情:
class PillFab @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) :
FloatingActionButton(context, attrs, defStyleAttr) {
init {
val shapeAppearanceModel =
ShapeAppearanceModel(context, attrs, defStyleAttr, DEF_STYLE_RES, ShapeAppearanceModel.PILL)
shapeAppearance = shapeAppearanceModel
}
companion object …Run Code Online (Sandbox Code Playgroud) android material-design floating-action-button material-components material-components-android
我正在使用
implementation 'com.google.android.material:material:1.1.0-alpha09'
Run Code Online (Sandbox Code Playgroud)
这是我的菜单
<item
android:id="@+id/llHome"
android:icon="@drawable/selector_menu_home"
android:title="@string/navigation.bottom.home"
app:tooltipText="@null" />
Run Code Online (Sandbox Code Playgroud)
但是只要我写长按或禁用它,带有菜单名称的工具提示就会继续出现。知道如何禁用工具提示吗?