首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Android 5材料设计问题

Android 5材料设计问题
EN

Stack Overflow用户
提问于 2015-07-05 23:38:39
回答 1查看 403关注 0票数 0

我对android程序很陌生,我刚刚发现了什么是材料设计。

我有几个问题

  1. 我怎样才能制作像google +或google应用程序这样的图标呢?(它们有阴影,和其他的有点不同)。
  2. 如何将材料设计添加到我的应用程序中?(状态栏之类的.)
  3. 我怎么才能做手帕??关于状态栏的颜色,我看到一些应用程序标题栏更轻,状态栏更暗--我不希望我的应用程序变成那样--我能做些什么呢?
  4. 如何使我的应用程序在更低的app上运行?噢,我在使用eclipse,请不要给我谷歌开发者的链接,因为我们的国家是被禁止的
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-06 01:34:05

关于#1,

代码语言:javascript
运行
复制
Right click on 'app' or the beginning of your project tree > New > Image Asset

你应该能够自定义图标的大部分方面,如果不是全部的话。

关于#2,

代码语言:javascript
运行
复制
I don't understand exactly what you're asking. You can customize your Action Bar and stuff like that if you choose.

关于#3,

转到res ->可绘图,右键单击并创建一个新的可绘制资源,并将其命名为circle.xml。现在,在新创建的文件中添加以下代码:

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item android:top="8px">
    <layer-list>
        <item>
            <shape android:shape="oval">
                <solid android:color="#08000000"/>
                <padding
                    android:bottom="3px"
                    android:left="3px"
                    android:right="3px"
                    android:top="3px"
                    />
            </shape>
        </item>
        <item>
            <shape android:shape="oval">
                <solid android:color="#09000000"/>
                <padding
                    android:bottom="2px"
                    android:left="2px"
                    android:right="2px"
                    android:top="2px"
                    />
            </shape>
        </item>
        <item>
            <shape android:shape="oval">
                <solid android:color="#10000000"/>
                <padding
                    android:bottom="2px"
                    android:left="2px"
                    android:right="2px"
                    android:top="2px"
                    />
            </shape>
        </item>
        <item>
            <shape android:shape="oval">
                <solid android:color="#11000000"/>
                <padding
                    android:bottom="1px"
                    android:left="1px"
                    android:right="1px"
                    android:top="1px"
                    />
            </shape>
        </item>
        <item>
            <shape android:shape="oval">
                <solid android:color="#12000000"/>
                <padding
                    android:bottom="1px"
                    android:left="1px"
                    android:right="1px"
                    android:top="1px"
                    />
            </shape>
        </item>
        <item>
            <shape android:shape="oval">
                <solid android:color="#13000000"/>
                <padding
                    android:bottom="1px"
                    android:left="1px"
                    android:right="1px"
                    android:top="1px"
                    />
            </shape>
        </item>
        <item>
            <shape android:shape="oval">
                <solid android:color="#14000000"/>
                <padding
                    android:bottom="1px"
                    android:left="1px"
                    android:right="1px"
                    android:top="1px"
                    />
            </shape>
        </item>
        <item>
            <shape android:shape="oval">
                <solid android:color="#15000000"/>
                <padding
                    android:bottom="1px"
                    android:left="1px"
                    android:right="1px"
                    android:top="1px"
                    />
            </shape>
        </item>

    </layer-list>
</item>

<item >

    <ripple xmlns:android="http://schemas.android.com/apk/res/android"
        android:color="?android:colorControlHighlight">
        <item android:id="@android:id/mask">
            <shape android:shape="oval">
                <solid android:color="#FFBB00" />
            </shape>
        </item>
        <item>
            <shape android:shape="oval">

                <solid android:color="@color/ColorPrimary" />


            </shape>
        </item>
    </ripple>

</item>

您必须注意,圆形的形状被封装在一个波纹标签中,这个标签确保圆圈在接触到棒棒糖装置上的波纹效应时作出反应。现在转到res ->布局,右键单击并选择create新布局资源,将其命名为tool_bar.xml,并将以下代码添加到该文件中:

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="utf-8"?>

<android.support.v7.widget.Toolbar
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:elevation="2dp"
android:theme="@style/Base.ThemeOverlay.AppCompat.Dark"
android:background="@color/ColorPrimary"
xmlns:android="http://schemas.android.com/apk/res/android" />

现在转到res ->值,创建一个新的资源文件名为colors.xml,并添加以下代码:

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ColorPrimary">#FF5722</color>
<color name="ColorPrimaryDark">#E64A19</color> // you can change the colors if you want, this is orange
</resources>

现在转到activity_main.xml并向其添加以下代码。还请确保您添加图标,您想要显示在您的FAB到您的项目。

代码语言:javascript
运行
复制
<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=".MainActivity">

<include
    android:id="@+id/toolbar"
    layout="@layout/tool_bar"

    ></include>

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentEnd="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:id="@+id/frameLayout">

    <TextView
        android:id="@+id/TextAct1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_centerVertical="true"
        android:layout_gravity="center"
        android:text="Edit this to say anything"
        android:textSize="25dp" />

    <ImageButton
        android:layout_margin="15dp"
        android:layout_width="70dp"
        android:layout_height="70dp"
        android:src="@drawable/ic_action"
        android:background="@drawable/circle"
        android:id="@+id/imageButton"
        android:layout_gravity="right|bottom" />


</FrameLayout>
</RelativeLayout>

来源:数字3:http://www.android4devs.com/2015/03/how-to-make-floating-action-button-fab.html

关于#4,

使用Eclipse,它可能无法正确地更改SDK版本,只需右键单击和属性即可。打开清单文件并更改行:

代码语言:javascript
运行
复制
<uses-sdk android:minSdkVersion="number-of-version-you-want" />

资料来源:数字4:Eclipse Android Change API Level

祝你好运,如果可以的话,看看这些链接。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31236053

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档