试图移动我的东西Toolbar而不是动作栏,但我不断收到错误说
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tyczj.weddingalbum/com.xxx.xxx.MainActivity}: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5039)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. …Run Code Online (Sandbox Code Playgroud) android android-actionbar material-design android-5.0-lollipop android-toolbar
我想换ListView到RecyclerView.我想使用onScroll的的OnScrollListener在RecyclerView确定用户滚动到列表的末尾.
如何知道用户是否滚动到列表末尾以便我可以从REST服务获取新数据?
android listview onscrolllistener material-design android-recyclerview
我对材料设计的按钮样式感到困惑.我想得到彩色凸起的按钮,如附带的链接,就像在使用部分下看到的"强制停止"和"卸载"按钮一样.是否有可用的样式或我需要定义它们?
http://www.google.com/design/spec/components/buttons.html#buttons-usage
我找不到默认的按钮样式.
例:
<Button style="@style/PrimaryButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Calculate"
android:id="@+id/button3"
android:layout_below="@+id/editText5"
android:layout_alignEnd="@+id/editText5"
android:enabled="true" />
Run Code Online (Sandbox Code Playgroud)
如果我尝试通过添加更改按钮的背景颜色
android:background="@color/primary"
Run Code Online (Sandbox Code Playgroud)
所有的风格都消失了,比如触摸动画,阴影,圆角等.
我有一个ListView,每个列表项我希望它在它下面显示一个阴影.我正在使用Android Lollipop的新高程功能在View上设置一个我想要投射阴影的Z,并且我已经使用ActionBar(技术上是Lollipop中的工具栏)有效地做到了这一点.我正在使用Lollipop的高程,但由于某种原因,它没有在列表项下显示阴影.以下是每个列表项的布局设置方式:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
style="@style/block"
android:gravity="center"
android:layout_gravity="center"
android:background="@color/lightgray"
>
<RelativeLayout
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:elevation="30dp"
>
<ImageView
android:id="@+id/documentImageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/alphared"
android:layout_alignParentBottom="true" >
<appuccino.simplyscan.Extra.CustomTextView
android:id="@+id/documentName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
app:typeface="light"
android:paddingLeft="16dp"
android:paddingTop="8dp"
android:paddingBottom="4dp"
android:singleLine="true"
android:text="New Document"
android:textSize="27sp"/>
<appuccino.simplyscan.Extra.CustomTextView
android:id="@+id/documentPageCount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
app:typeface="italic"
android:paddingLeft="16dp"
android:layout_marginBottom="16dp"
android:text="1 page"
android:textSize="20sp"/>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
但是,这是它如何显示列表项,没有阴影:
我也试过以下无济于事:
在AppCompat今天发布更新之前,我能够更改Android L中按钮的颜色,但不能更改旧版本.包含新的AppCompat更新后,我无法更改任何一个版本的颜色,当我尝试按钮时就消失了.有谁知道如何更改按钮颜色?
以下图片显示了我想要实现的目标:

白色按钮是默认的,红色按钮是我想要的.
这是我之前做的改变以下按钮颜色的方法styles.xml:
<item name="android:colorButtonNormal">insert color here</item>
Run Code Online (Sandbox Code Playgroud)
并动态地做:
button.getBackground().setColorFilter(getResources().getColor(insert color here), PorterDuff.Mode.MULTIPLY);
Run Code Online (Sandbox Code Playgroud)
我也确实将主题父@android:style/Theme.Material.Light.DarkActionBar改为Theme.AppCompat.Light.DarkActionBar
我正在开发一个我正在使用的Android应用程序RecyclerView.我需要添加一个分压器在RecyclerView.我试着添加 -
recyclerView.addItemDecoration(new
DividerItemDecoration(getActivity(),
DividerItemDecoration.VERTICAL_LIST));
Run Code Online (Sandbox Code Playgroud)
下面是我的xml代码 -
<android.support.v7.widget.RecyclerView
android:id="@+id/drawerList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
/>
Run Code Online (Sandbox Code Playgroud) 在谷歌推出Material Design之后,我听说过一个名为Toolbar的新小部件类.
什么是工具栏,ActionBar和ToolBar之间的确切区别是什么?
我将使用AngularJS(完整堆栈)开始新项目.我的项目需要响应,我将从头开始创建模板.
所以我需要一个关于是否选择bootstrap 3(带角度指令)或布局材料设计的建议?
如果有人能列出两者的优点和缺点,我将不胜感激.
angularjs twitter-bootstrap-3 material-design angular-material
我想在按钮点击上添加一个涟漪动画.我确实喜欢下面但它需要minSdKVersion到21.
ripple.xml
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:colorControlHighlight">
<item>
<shape android:shape="rectangle">
<solid android:color="?android:colorAccent" />
</shape>
</item>
</ripple>
Run Code Online (Sandbox Code Playgroud)
按键
<com.devspark.robototextview.widget.RobotoButton
android:id="@+id/loginButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ripple"
android:text="@string/login_button" />
Run Code Online (Sandbox Code Playgroud)
我想让它向后兼容设计库.
怎么做到这一点?
我已将appCompat材质设计添加到我的应用程序中,似乎警报对话框未使用我的primary,primaryDark或强调颜色.
这是我的基本风格:
<style name="MaterialNavyTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/apptheme_color</item>
<item name="colorPrimaryDark">@color/apptheme_color_dark</item>
<item name="colorAccent">@color/apptheme_color</item>
<item name="android:textColorPrimary">@color/action_bar_gray</item>
</style>
Run Code Online (Sandbox Code Playgroud)
根据我的理解,对话框按钮文本也应该使用这些颜色.我的理解是错的还是我还需要做些什么?
解:
明确的答案让我走上正轨.
<style name="MaterialNavyTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/apptheme_color</item>
<item name="colorPrimaryDark">@color/apptheme_color_dark</item>
<item name="colorAccent">@color/apptheme_color</item>
<item name="android:actionModeBackground">@color/apptheme_color_dark</item>
<item name="android:textColorPrimary">@color/action_bar_gray</item>
<item name="sdlDialogStyle">@style/DialogStyleLight</item>
<item name="android:seekBarStyle">@style/SeekBarNavyTheme</item>
</style>
<style name="StyledDialog" parent="Theme.AppCompat.Light.Dialog">
<item name="colorPrimary">@color/apptheme_color</item>
<item name="colorPrimaryDark">@color/apptheme_color_dark</item>
<item name="colorAccent">@color/apptheme_color</item>
</style>
Run Code Online (Sandbox Code Playgroud) android android-appcompat android-support-library material-design material-components-android
material-design ×10
android ×9
button ×2
android-view ×1
angularjs ×1
listview ×1
material-components-android ×1
shadow ×1