我正在尝试扩展其中一个Material组件MdTabGroup.使用开箱即用的MdTabGroup组件一切正常 - 材料库正确导入模块等.
这是扩展组件:
@Component({
selector: 'md-custom-tab-group',
templateUrl: 'custom-tab-group.html',
....
})
export class MdCustomTabGroup extends MdTabGroup {
constructor( private _r : Renderer) {
super(_r);
}
}
Run Code Online (Sandbox Code Playgroud)
新组件在app模块中导入并声明,因此创建:
<md-custom-tab-group>
<md-tab>one</md-tab>
<md-tab>two</md-tab>
</md-custom-tab-group>
Run Code Online (Sandbox Code Playgroud)
自定义选项卡组(custom-tab-group.html)的模板与材质中的模板相同,例如
<div class="mat-tab-body-wrapper" #tabBodyWrapper>
<md-tab-body role="tabpanel"
*ngFor="let tab of _tabs; let i = index"
...
[content]="tab.content"
...>
</md-tab-body>
</div>
Run Code Online (Sandbox Code Playgroud)
运行时,_tabsViewChildren集合将正确填充 - 它包含md-tab原始标记中的声明,解释为"材质"选项卡组件.但是,custom-tab-group.html模板是不是有效.模板解析器现在不知道'md-tab-body'是什么.
具体 -
无法绑定到'content',因为它不是'md-tab-body'的已知属性.
但是当我拿起新模板时,我认为它根本不知道md-tab-body是什么.
问题是 - 如何纠正此行为并使扩展组件正常工作?
我在md-tab-group中有以下图标:
<md-tab-group>
<md-tab *ngFor="let tab of arrayOfTabs">
<ng-template md-tab-label>
<md-icon (click)="changetab()">close</md-icon>
</ng-template>
My Tab Content
</md-tab>
</md-tab-group>
Run Code Online (Sandbox Code Playgroud)
我想这样做,而不是"关闭"材料图标,将其更改为"星形"图标.如何通过针对该特定选项卡的图标上的单击事件来实现此目的?
Android Instant Apps文档在限制功能部分中说明它不能:
我不完全理解上述声明,但听起来它可能不接受任何第三方软件或除了库中给出的任何本地库SDK/NDK.
有人可以帮忙详细说明吗?
我正在尝试使用 .angular4 项目创建mdc-componentsangular-cli。所以我使用 npm 命令安装了 moduled
npm install material-components-web
Run Code Online (Sandbox Code Playgroud)
这个安装了
"material-components-web": "^0.22.0"
Run Code Online (Sandbox Code Playgroud)
然后创建了一个包含滑块的 HTML 标记的组件
<div #slider class="mdc-slider" tabindex="0" role="slider" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" aria-label="Select Value">
<div class="mdc-slider__track-container">
<div class="mdc-slider__track"></div>
</div>
<div class="mdc-slider__thumb-container">
<svg class="mdc-slider__thumb" width="21" height="21">
<circle cx="10.5" cy="10.5" r="7.875"></circle>
</svg>
<div class="mdc-slider__focus-ring"></div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
在 ts 端使用 ViewChild
@ViewChild('slider') elSlider: ElementRef;
Run Code Online (Sandbox Code Playgroud)
并使用MDCSlider类包装此元素
let mdcSlider = new MDCSlider(this.elSlider.nativeElement);
Run Code Online (Sandbox Code Playgroud)
然后为文件中的同一个 mdc 组件导入 sassstyles.scss文件
@import '~@material/slider/mdc-slider';
Run Code Online (Sandbox Code Playgroud)
这在 UI 上呈现了一个漂亮的材质滑块组件,并且工作正常。
监听更改事件
mdcSlider.listen('MDCSlider:change', () => console.log("Value changed …Run Code Online (Sandbox Code Playgroud) Android 应用程序突然拒绝构建,它返回此错误:
Android资源链接失败错误:找不到资源style/Theme.MaterialComponents.Light.NoActionBar(又名it.duemilanet.icircle:style/Theme.MaterialComponents.Light.NoActionBar)。
D:\GitLab\iCircleAndroidRMA\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1440: 错误: 样式属性 'attr/colorSecondary (又名 it.duemilanet.icircle:attr/colorSecondary)'未找到。错误:找不到资源 style/Widget.Design.BottomSheet.Modal (又名 it.duemilanet.icircle:style/Widget.Design.BottomSheet.Modal)。错误:找不到资源样式/Theme.Design.Light.BottomSheetDialog(又名 it.duemilanet.icircle:style/Theme.Design.Light.BottomSheetDialog)。D:\GitLab\iCircleAndroidRMA\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:3296: 错误: 样式属性 'attr/bottomSheetStyle (又名 it.duemilanet.icircle:attr/bottomSheetStyle)'未找到。错误:链接引用失败。
之前编译得很好,几周前我切换到 androidX 和材料组件主题并启用 jetifier 没有问题
构建.gradle:
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0-alpha09'
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2'
classpath 'com.google.gms:google-services:4.0.2'
classpath 'io.fabric.tools:gradle:1.25.4'
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url 'https://maven.google.com/'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
应用程序构建.gradle:
apply plugin: 'com.android.application'
apply plugin: 'org.greenrobot.greendao'
apply plugin: 'io.fabric'
android { …Run Code Online (Sandbox Code Playgroud) 我使用Angular Material Tabs并且需要一个钩子来检查用户是否可以更改选项卡(表单未/保存)。我找不到任何 API 功能来防止选项卡更改。有任何想法吗?谢谢
我迁移到androidx并且我的依赖项是:
implementation 'androidx.appcompat:appcompat:1.1.0-alpha05'
implementation 'com.google.android.material:material:1.1.0-alpha06'
Run Code Online (Sandbox Code Playgroud)
我用过FloatingActionButton:
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_margin="15dp"
app:backgroundTint="@color/colorAccent"
app:srcCompat="@drawable/ic_add_32dp"/>
Run Code Online (Sandbox Code Playgroud)
但是当我放置时FloatingActionButton,XML 崩溃(渲染问题)。即使我使用以下内容:
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
Run Code Online (Sandbox Code Playgroud)
但是这个错误只出现在XML中,不影响程序的执行,design mode我也没有显示。问题invalidate Cache and Restart在于它暂时解决了问题,但它再次发生。
渲染问题是:
java.lang.IllegalArgumentException: java.lang.ClassCastException@7e11486d at java.lang.reflect.Method.invoke(Method.java:498) at android.animation.PropertyValuesHolder_Delegate.callMethod(PropertyValuesHolder_Delegate.java:108) at PropertyValuesHolder_Delegate.nCallFloatMethod(PropertyValuesHolder_Delegate.java:143) at android.animation.PropertyValuesHolder.nCallFloatMethod(PropertyValuesHolder.java:-1) at android.animation.PropertyValuesHolder.access$400(Property.java:HolderValuesHolder) at android.animation.PropertyValuesHolder.nCallFloatMethod(PropertyValuesHolder.java:-1) .setAnimatedValue(PropertyValuesHolder.java:1387) at android.animation.ObjectAnimator.animateValue(ObjectAnimator.java:990) at android.animation.ValueAnimator.setCurrentFraction(ValueAnimator.java:674) at android.animation.ValueAnimator。setCurrentPlayTime(ValueAnimator.java:637) at android.animation.ValueAnimator.start(ValueAnimator.java:1069) at android.animation.ValueAnimator.start(ValueAnimator.java:1088) at android.animation.ObjectAnimator.start(ObjectAnimator.java) :852) 在 android.animation.ValueAnimator.startWithoutPulsing(ValueAnimator.java:1081) 在 android.animation.AnimatorSet.handleAnimationEvents(AnimatorSet.java:1142) 在 android.animation.AnimatorSet.startAnimation(AnimatorSet.java:1227) 在 android .animation.AnimatorSet.start(AnimatorSet.java:729) at android.animation.AnimatorSet.start(AnimatorSet.java:684) at android.animation.StateListAnimator.start(StateListAnimator.java:188) at android.animation.StateListAnimator。 …
我正在开发一个 android 应用程序,该应用程序使用过滤器对图像应用过滤器LayerDrawable并将这些图像保存到 pdf 文件,但问题在于,当我增加任何图像的尺寸时1000x1300,图像不会pdf在 .底部就像这张图片(将图片上传到 stackoverflow 时出现了一些问题,所以我必须使用这种方法)。
我使用setBounds()方法设置尺寸,以下是我用于将图像保存为 pdf 的代码(可能的问题来源被注释为//----->here lies the issue)。
override fun doInBackground(vararg p0: Void?): String {
// create a new document
val document = PdfDocument()
var numberOfPages = mainList.size / 10
if (mainList.size % 10 != 0) {
numberOfPages++
}
var count = 1
var innerCounter = 1
while (count <= numberOfPages) {
// crate a page description
val pageInfo: PdfDocument.PageInfo =
PdfDocument.PageInfo.Builder(2480, …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Material 提供的 CircularProgress。
我创建了这个组件来改变它的颜色:
import React, { Component } from 'react';
import { withStyles } from '@material-ui/core/styles';
import { CircularProgress } from '@material-ui/core';
class ColoredCircularProgress extends Component {
render() {
const { classes } = this.props;
return <CircularProgress {...this.props} classes={{colorPrimary: classes.colorPrimary}}/>;
}
}
const styles = props => ({
colorPrimary: {
backgroundColor: '#FD8907',
}
});
export default withStyles(styles)(ColoredCircularProgress);
Run Code Online (Sandbox Code Playgroud)
但是在我的网站上它看起来像这样:
我的问题是:
我希望圆圈看起来是橙色的,而圆圈看起来仍然是蓝色的,它在后面添加了一个橙色的方形框。
它也显示在我网站的左上角。我怎样才能把它放在中间?
所以我开始了一个新的 android 应用程序,
这是我的 Android Studio 信息
Android Studio 3.6.1
Build #AI-192.7142.36.36.6241897, built on February 27, 2020
Runtime version: 1.8.0_212-release-1586-b04 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 7 6.1
Run Code Online (Sandbox Code Playgroud)
我还加了
buildConfigField "String", "MODE", "FREE"
Run Code Online (Sandbox Code Playgroud)
在我的产品风味中。
当我现在在我的 MainActivity 的 onCreate 中得到这个时,
BuildConfig
Run Code Online (Sandbox Code Playgroud)
是未解决的参考。
android ×5
angular ×4
kotlin ×2
material-components-android ×2
androidx ×1
buildconfig ×1
inheritance ×1
javascript ×1
material-ui ×1
reactjs ×1
tabs ×1
themes ×1