将v7 appcompat支持库添加到我的build.gradle中,我可以毫无问题地使用ActionBarActivity.但如果我换ActionBarActivity了AppCompatActivity,我得到:
./gradlew assembleDebug
:preBuild
:compileDebugNdk UP-TO-DATE
:preDebugBuild
:checkDebugManifest
:preReleaseBuild
:prepareComAndroidSupportAppcompatV72200Library UP-TO-DATE
:prepareComAndroidSupportSupportV42200Library UP-TO-DATE
:prepareDebugDependencies
:compileDebugAidl UP-TO-DATE
:compileDebugRenderscript UP-TO-DATE
:generateDebugBuildConfig UP-TO-DATE
:generateDebugAssets UP-TO-DATE
:mergeDebugAssets UP-TO-DATE
:generateDebugResValues UP-TO-DATE
:generateDebugResources UP-TO-DATE
:mergeDebugResources UP-TO-DATE
:processDebugManifest UP-TO-DATE
:processDebugResources UP-TO-DATE
:generateDebugSources UP-TO-DATE
:compileDebugJava
MainActivity.java:4: error: cannot find symbol
import android.support.v7.app.AppCompatActivity;
Run Code Online (Sandbox Code Playgroud)
MainActivity.java:
package app.test.v7.support;
// replacing ActionBarActivity with AppCompatActivity fails.
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
// replacing ActionBarActivity with AppCompatActivity fails.
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) { …Run Code Online (Sandbox Code Playgroud) 我FloatingActionButton在图像下方显示浅灰色.任何人都知道如何删除它.我在Lollipop版本上进行了测试.
我的xml代码
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:src="@drawable/ic_add_black"
app:borderWidth="0dp"
app:fabSize="mini"
app:rippleColor="@color/colorPrimaryDark" />
Run Code Online (Sandbox Code Playgroud)
我为我的项目使用android.support库,我使用android 4.4开发了我的应用程序并且一切正常但我的问题出现在我尝试在Android Lollipop设备中运行应用程序时.
当它使用工具栏加载Activity时,应用程序将停止并返回此错误.
扩展类android.support.v7.widget.Toolbar时出错
我在互联网上发现了同样的问题,但我没有在答案中找到解决方案.
这是我的styles.xml
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<!-- Base theme applied no matter what API -->
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/dark_primary</item>
<item name="colorAccent">@color/accent_color</item>
</style>
Run Code Online (Sandbox Code Playgroud)
这是我的styles.xml(v22)
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material.Light.NoActionBar">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/dark_primary</item>
<item name="colorAccent">@color/accent_color</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
在.xml中定义工具栏
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mitoolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
local:popupTheme="@style/ThemeOverlay.AppCompat.Light"
tools:showIn="@layout/activity_main" /> …Run Code Online (Sandbox Code Playgroud) android android-support-library android-styles android-5.0-lollipop
我正在构建一个关于Material Design的应用程序,我想知道如何在滚动时隐藏FAB.谷歌搜索导致几个答案,有些人说提供自定义onScrollListeners等,有些人说实现布局行为.是否有标准/推荐的方法来做到这一点?一种方法比另一种方法有什么优势?
android android-support-library material-design floating-action-button android-design-library
我正在使用appcompat使用com.android.support:appcompat-v7:23.0.3并获得以下错误的Android应用程序.
错误:(22,9)错误:类AppCompatActivity中的方法setSupportActionBar不能应用于给定类型; 需要:android.support.v7.widget.Toolbar发现:android.widget.Toolbar原因:实际参数android.widget.Toolbar无法通过方法调用转换转换为android.support.v7.widget.Toolbar
android android-appcompat android-support-library android-actionbar-compat android-toolbar
我刚刚更新到稳定的Xamarin.Android(5.1.7.12),它支持Android API 23(6.0).
我已将TargetFrameworkVersion更新为v6.0(API 23),并且我已将所有支持库更新到版本23.0.1.1(当时可用的最新NuGet包).我已经下载了所有需要编译到API23(Android SDK Manager中的SDK和BuildTools).
当我尝试编译此项目时,我收到此错误:
...
...\obj\Debug\resourcecache\983D70AD6A5CC1E0AF6E3C8A8BE731EB\res\values\values.xml(10): error APT0000: Attribute "cardBackgroundColor" has already been defined
...\obj\Debug\resourcecache\983D70AD6A5CC1E0AF6E3C8A8BE731EB\res\values\values.xml(10): error APT0000: Attribute "cardCornerRadius" has already been defined
...\obj\Debug\resourcecache\983D70AD6A5CC1E0AF6E3C8A8BE731EB\res\values\values.xml(10): error APT0000: Attribute "cardElevation" has already been defined
...\obj\Debug\resourcecache\983D70AD6A5CC1E0AF6E3C8A8BE731EB\res\values\values.xml(10): error APT0000: Attribute "cardMaxElevation" has already been defined
...\obj\Debug\resourcecache\983D70AD6A5CC1E0AF6E3C8A8BE731EB\res\values\values.xml(10): error APT0000: Attribute "cardUseCompatPadding" has already been defined
...\obj\Debug\resourcecache\983D70AD6A5CC1E0AF6E3C8A8BE731EB\res\values\values.xml(10): error APT0000: Attribute "cardPreventCornerOverlap" has already been defined
...\obj\Debug\resourcecache\983D70AD6A5CC1E0AF6E3C8A8BE731EB\res\values\values.xml(10): error APT0000: Attribute "contentPadding" has already been defined
...\obj\Debug\resourcecache\983D70AD6A5CC1E0AF6E3C8A8BE731EB\res\values\values.xml(10): error APT0000: Attribute "contentPaddingLeft" has already been …
当我更新我的职场sdks.我正在警告这条线.
Palette.GenerateAsync(bitmap)
Run Code Online (Sandbox Code Playgroud)
方法Android.Support.Graphics.V7.Palette.Generate是不推荐使用的消息,因此这是生成调色板的最佳方法.
注意:
Java Code也很受欢迎
我的应用程序中有2个模块,我想修改它们以使用AppCompat Widgets,我必须使用它来扩展它们.问题是我不想为每个人添加appcompat依赖,所以我怎么可能将依赖添加到模块和我的应用程序.如果我确实添加
compile 'com.android.support:appcompat-v7:23.1.1'
Run Code Online (Sandbox Code Playgroud)
对于每个模块,它会影响应用程序的大小吗?
android gradle android-support-library build.gradle android-gradle-plugin
当选择导航抽屉中的项目时,左抽屉和片段会发生变化.问题是,如果已经选择了"项目A",并且用户再次选择它,则对于相同的片段更改片段.
为防止出现这种情况,我需要知道哪个项目已被选中.我使用的是属性mLastSelectedItemPosition,但我不认为这是一个很好的解决方案.有没有办法从导航抽屉中获取当前检查的项目?
class OnNavigationItemSelectedListener implements NavigationView.OnNavigationItemSelectedListener {
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
if (mLastSelectedItemPosition != menuItem.getOrder()) {
// Is not the same item, so I can change the fragment.
mLastSelectedItemPosition = menuItem.getOrder();
}
mDrawerLayout.closeDrawers();
return true;
}
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用支持库中的FloatingActionButton.我注意到只能使用属性app在fab中更改大小:fab_size ="".
我查看了源代码,并且没有方法可以在app运行时更改fab大小.
我只是想根据用户输入在MINI和NORMAL之间改变fab的大小,所以我需要以编程方式进行.
有没有人找到办法做到这一点?
android android-support-library floating-action-button androiddesignsupport