我是Android编程的新手,我刚刚发现了什么材料设计。
我有一些问题
答案 0 :(得分:0)
如果您无法查看开发者网站,则可以查看代码示例。您可以使用SDK管理器下载示例。
例如,在Lollipop SDK中的samples文件夹/ ui / views中,您可以找到FloatingActionButton
,CardView
,Elevation
,RevealEffect
等许多其他人的示例。< / p>
答案 1 :(得分:0)
关于#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 - &gt; 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 - &gt;右键单击并选择创建新的布局资源,将其命名为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 - &gt; 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 Change API Level
古德勒克,如果可以,请查看链接。