Android 5材质设计问题

MJ Zakar

我是android编程的新手,我只是发现什么是材料设计。

我有几个问题

  1. 如何制作Google+或Google应用程序之类的图标?(有阴影,与其他阴影略有不同)
  2. 如何向我的应用添加材质设计?(状态栏和类似的东西...)
  3. 我该如何制造FAB?关于状态栏的颜色,我已经看到一些应用程序的标题栏较亮,而状态栏较暗,我不希望我的应用程序像那样,我该怎么办?
  4. 如何使我的应用程序在较低的API上运行?哦,我正在使用eclipse,请不要给我指向Google开发人员的链接,因为我们所在的国家/地区被禁止
micoror1

关于#1

Right click on 'app' or the beginning of your project tree > New > Image Asset

您应该能够在那里自定义图标的大部分(如果不是全部)方面。

关于#2

I don't understand exactly what you're asking. You can customize your Action Bar and stuff like that if you choose.

关于#3

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

<?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-> layout上,单击鼠标右键,然后选择创建一个新的布局资源,将其命名为tool_bar.xml,并将以下代码添加到该文件中:

<?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-> values创建一个新的资源文件,命名为colors.xml并添加以下代码:

<?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内部显示的图标添加到项目中。

<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版本。打开清单文件并更改以下行:

<uses-sdk android:minSdkVersion="number-of-version-you-want" />

数字4的来源:Eclipse Android更改API级别

祝您好运,请检查链接。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

支持Android材质设计

来自分类Dev

Android材质设计故障

来自分类Dev

材质设计的Android颜色

来自分类Dev

Android材质设计故障

来自分类Dev

材质设计的Android颜色

来自分类Dev

覆盖按钮材质设计android

来自分类Dev

Eclipse中的Android材质设计

来自分类Dev

崩溃-材质设计android 5.0

来自分类Dev

Android TimePickerDialog材质设计颜色

来自分类Dev

android 5.0材质设计选项卡

来自分类Dev

列表视图中的Android材质设计混乱

来自分类Dev

Android切换按钮-材质设计

来自分类Dev

Android工具栏/ SupportActionBar的材质设计

来自分类Dev

Android材质设计:删除提示动画

来自分类Dev

材质设计清单指南Android 5.0

来自分类Dev

kivy浮动按钮android材质设计风格

来自分类Dev

Android:设计布局问题

来自分类Dev

设计问题 Android 平台

来自分类Dev

Android多屏设计问题

来自分类Dev

Android多屏设计问题

来自分类Dev

Android 相对布局设计问题

来自分类Dev

为什么我的材质设计无法正确渲染(Android Studio)?

来自分类Dev

KitKat的Android 5.0材质设计样式导航抽屉

来自分类Dev

Android-材质设计:带有滑动标签的Tabstrip(标题)

来自分类Dev

如何创建Android材质设计UI小部件?

来自分类Dev

Android材质设计-圆角视图无法正确显示圆角阴影

来自分类Dev

覆盖android材质设计警报对话框

来自分类Dev

如何在Android材质设计样式中创建按钮阴影

来自分类Dev

Android L-SwipeRefreshLayout配色方案上的材质设计