标签: material-design

Android - 在 xml 中的材质主题中隐藏操作栏

我使用的主题继承自"android:Theme.Material.Light"xml 样式自定义,但无法找到隐藏操作栏的方法。使用时"Theme.AppCompat.Light"我可以用这样的东西来做

<style name="MyTheme" parent="Theme.AppCompat.Light">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
</style>
Run Code Online (Sandbox Code Playgroud)

我怎样才能用材料主题达到类似的结果?我知道您可以通过编程方式隐藏它,但这不仅不方便,因为您实际上无法在不必每次运行应用程序的情况下看到 Android Studio 上的真实布局,而且,当您运行该应用程序时,操作栏仍然会出现一秒钟应用程序,在getActionBar().hide()运行之前,它看起来很不专业。

解决方案:

<style name="MyTheme" parent="android:Theme.Material.Light">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowActionBar">false</item>
</style>
Run Code Online (Sandbox Code Playgroud)

android material-design android-5.0-lollipop

1
推荐指数
1
解决办法
7405
查看次数

更改工具栏文本颜色

我正在尝试更改工具栏的文本颜色,但无济于事。这是我的代码。

样式文件

<!-- Base application theme. -->
<style name="BasicTheme" parent="Theme.AppCompat.Light.NoActionBar">

</style>
<style name="ToolbarTheme" parent="BasicTheme">
    <item name="android:textColor">@color/text_color</item>
</style>
Run Code Online (Sandbox Code Playgroud)

工具_lay

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar     
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   xmlns:appo="http://schemas.android.com/tools"
   android:orientation="vertical"
   android:layout_width="match_parent"
   android:layout_height="?attr/actionBarSize"
   android:id="@+id/toolbar"
   android:elevation="10dp"
   android:background="@color/colorPrimary"
   appo:theme="@style/ToolbarTheme"
 >
Run Code Online (Sandbox Code Playgroud)

活动_main.xml

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout 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"

tools:context="testing.theo.aelfootballclub.MainActivity"
android:background="#3d827e">
<include

    android:id="@+id/toolbar"
    layout="@layout/tool_lay"

    />
<LinearLayout
    android:padding="20dp"
    android:background="#6e7398"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:layout_width="wrap_content"
    android:orientation="vertical"
    android:layout_height="wrap_content">

    <EditText
        android:id="@+id/user_name"
        android:hint="Userame"
        android:layout_width="250dp"
        android:layout_height="wrap_content" />
    <EditText
        android:id="@+id/user_pass"
        android:layout_width="250dp"
        android:layout_height="wrap_content"
        android:inputType="textPassword"
        android:layout_marginTop="20dp"
        android:hint="???????"
        />
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <Button
            android:layout_gravity="center_horizontal"
            android:text="???????"
            android:layout_marginTop="20dp"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

android toolbar material-design

1
推荐指数
1
解决办法
5573
查看次数

如何创建一个完全透明的导航栏?

我想将导航栏更改为完全透明,如下图所示。

我试过了,<item name="android:windowTranslucentNavigation">true</item>但它不是完全透明的(更像是 50%)。

有解决办法吗?因为我一无所获,但我看到了一些像 Nova 这样使用它的应用程序。它甚至在谷歌指南https://material.google.com/layout/structure.html#structure-system-bars

透明导航

android android-layout material-design

1
推荐指数
1
解决办法
7838
查看次数

没有阴影的材料设计按钮

我最近开始了 android 开发,但我有点挣扎。我阅读了有关创建可绘制对象等的不同文章和教程。


现在的情况

我创建了以下按钮:

社交登录按钮

使用以下代码:

    <android.support.v7.widget.AppCompatButton
        android:id="@+id/login_btn_facebook"
        android:layout_width="fill_parent"
        android:layout_height="60dp"
        android:drawableStart="@drawable/ic_btn_login_facebook"
        android:paddingLeft="16dp"
        android:paddingRight="16dp"
        android:text="Continue with Facebook"
        android:textColor="#fff"
        app:backgroundTint="#3b5998"/>

    <android.support.v7.widget.AppCompatButton
        android:id="@+id/login_btn_google"
        android:layout_width="fill_parent"
        android:layout_height="60dp"
        android:drawableStart="@drawable/ic_btn_login_google"
        android:paddingLeft="16dp"
        android:paddingRight="16dp"
        android:text="Continue with Google"
        app:backgroundTint="#ffffff" />
Run Code Online (Sandbox Code Playgroud)

现在我实际上只需要一个小的改变:
我不想有海拔。我希望按钮是“平坦的”,并且仅在单击时显示阴影效果。

有没有一种简单的方法可以做到这一点?

已经谢谢了!


更新:
我需要将API 级别 19作为最低 SDK 版本。

android button flat material-design

1
推荐指数
1
解决办法
6819
查看次数

无法从未升高的透明 FloatingActionButton 中移除“阴影”

在花了几个小时研究这个问题后,我决定提出问题,而不是在这样一个(看似)简单的任务上浪费更多时间。

我正在尝试实现一个带有透明背景且没有 Broder 的 FloatingActionButton,以仅显示一个自定义图标。我知道材料设计不鼓励它,但我需要这样做。

我面临的问题是有阴影显示,这是我不想要的。由于我将高程设置为 0dp,我不知道它是如何到达那里的,因此我不知道如何将其删除。

有背景的 FAB 没有背景但有阴影的FAB

这是包含 FAB 的片段的代码:

<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/fragment_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_sample"
android:elevation="0dp"
android:fitsSystemWindows="true">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/fragment_grid"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:gravity="center"
        android:padding="10dp"
        android:stretchMode="columnWidth"
        android:verticalSpacing="25dp"/>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        style="@style/AppTheme"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|center"
        android:layout_marginBottom="@dimen/activity_vertical_margin"
        android:adjustViewBounds="true"
        android:elevation="0dp"
        android:fitsSystemWindows="true"
        android:scaleType="fitCenter"
        app:borderWidth="0dp"
        app:fabSize="normal"
        app:layout_anchorGravity="bottom|center"
        app:layout_behavior="ScrollAwareFABBehavior"
        />

</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

这是我的 AppTheme:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:fitsSystemWindows">true</item>
    <item name="android:spotShadowAlpha">0</item>
    <item name="android:shadowRadius">0</item>
    <item name="android:ambientShadowAlpha">0</item>
    <item name="selectableItemBackgroundBorderless">@null</item>
</style>
Run Code Online (Sandbox Code Playgroud)

我在其中设置透明性的 Fragment 的 onCreateView:

@Override
public final View onCreateView(final LayoutInflater inflater, final ViewGroup …
Run Code Online (Sandbox Code Playgroud)

android shadow material-design floating-action-button android-elevation

1
推荐指数
1
解决办法
3687
查看次数

如何在 Android 中使用类似标签的编辑文本

有什么方法可以在 StackOverflow 中创建一个类似于此处可用的相同标签系统的 EditText 吗?

或任何图书馆出于同样的目的?

我想在我的应用程序中做类似的事情:

我已经有一个 EditText 字段,用户输入一个主题,例如“java”,然后,当用户输入“;”时,我想用颜色、蓝色或灰色标记该词,例如突出显示它是一个标签。然后,用户可以输入另一个标签,即“android”,或者可以像文本一样删除前一个标签。

java android material-design

1
推荐指数
1
解决办法
2808
查看次数

如何在 Angular 5 中使用材料步进器

我目前对 Angular 有点陌生,我正试图弄清楚如何制作一个简单的步进器,它可以 (1) -- (2) -- (3)。

我有 html 作为 app.component.html

<mat-horizontal-stepper [linear]="true" #stepper>
    <mat-step label="Step 1">
        step 1
    </mat-step>
    <mat-step label="Step 2">
        step 2
    </mat-step>
</mat-horizontal-stepper>
Run Code Online (Sandbox Code Playgroud)

但是,我需要在打字稿中导入和执行哪些操作才能使其工作?我有 app.component.ts 作为

import { Component, ViewChild } from '@angular/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MatButtonModule } from '@angular/material';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})

export class AppComponent {
  @ViewChild('stepper') stepper;
  changeStep(index: number) {
    this.stepper.selectedIndex = index;
  }
}
Run Code Online (Sandbox Code Playgroud)

javascript frontend material-design angular-material2 angular

1
推荐指数
1
解决办法
2万
查看次数

在BottomNavigationView上为选定的图标设置动画

我正在寻找我目前在我的底形游览视图中使用的Vectordrawablawables,当为猫头鹰应用程序的本材料产品学习时选择了一个选项卡时。但是,与工具栏视图不同,当我使用 MenuItem.getIcon() 获取图标时,将其转换为 AnimatedVectorDrawable 并调用 animate() 方法,没有动画。

我想知道我是否可以做些什么来实现这一点,这是否可能包含在稳定的 Material Components 库中,或者我是否最好创建一个扩展 BottomNavigationView 类的自定义视图。

android material-design bottomnavigationview material-components material-components-android

1
推荐指数
1
解决办法
3060
查看次数

单击第一个菜单项后防止 MDC 菜单关闭

我们正在使用 MDC 菜单组件。我正在寻找一种在单击菜单中的第一项时不关闭菜单的方法。

我尝试将一个类应用于 mdc-list-item 并将光标指定为自动,但它不起作用。

.menu-do-not-close {
   cursor: auto !important;
}
Run Code Online (Sandbox Code Playgroud)

下面是示例小提琴

https://jsfiddle.net/phani25485/Lt6q2gxa/2/

您能否就如何实现这一目标提供一些指导。

javascript material-design material-components mdc-components material-components-web

1
推荐指数
1
解决办法
2090
查看次数

Flutter 中的平滑过渡状态

我在两种状态之间切换。一个是默认应用栏,另一个是搜索应用栏。我要问的是,我如何才能使过渡平稳,因为目前,它会立即从一种状态跳到另一种状态,并且看起来非常具有破坏性。这是我的代码:

@override
Widget build(BuildContext context) {
    var appBar;
    if(isSearching){
        appBar = AppBar(
            title: Text("SEARCH"),
            leading: IconButton(
                onPressed: (){
                        stopSearch();
                    },
                icon: Icon(Icons.arrow_back),
            ),
        );
    }else{
        appBar = AppBar(
            title: Text(widget.title),
            actions: <Widget>[
                IconButton(
                    onPressed: (){
                        startSearch();
                    },
                    icon: Icon(Icons.search, color: Colors.white,),
                ),
            ],
        );
    }

    return Scaffold(
        appBar: appBar,
        body: ListView(
            children: <Widget>[
                Text("PETER"),
                Text("PETER"),
                Text("PETER"),
                Text("PETER"),
            ],
        ),
    );
}
Run Code Online (Sandbox Code Playgroud)

我希望它像在材料设计文档上一样:https : //material.io/design/navigation/search.html#expandable-search

android-transitions material-design flutter

1
推荐指数
1
解决办法
1551
查看次数