- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
出于某种原因,我的工具栏
不会转换高程阴影。我什至尝试了 Java,但仍然无法正常工作。
关于为什么这没有达到预期效果有什么想法吗?我的应用不支持 Lollipop 之前的版本(最低 API 为 24)。
Activity XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/masterToolbar"
android:layout_width="match_parent"
android:layout_height="?actionBarSize">
<include layout="@layout/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"/>
</LinearLayout>
<RelativeLayout
android:id="@+id/master_container"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
工具栏 XML
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/my_toolbar"
android:elevation="4dp"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:minHeight="?android:attr/actionBarSize">
<LinearLayout
android:id="@+id/mytoolbar_textlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="@+id/mytoolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@android:style/TextAppearance.Material.Widget.ActionBar.Title"/>
</LinearLayout>
</android.support.v7.widget.Toolbar>
Activity 课
public class MyActivity extends AppCompatActivity {
private Boolean mCurrentValue;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.md);
}
@Override
protected void onStart() {
super.onStart();
setContentView(R.layout.md);
SharedPreferences mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
Boolean mNewValue = mSharedPreferences.getBoolean("my_preference", false);
if (mCurrentValue != mNewValue) {
recreate();
}
// ... do other stuff here
Resources r = getBaseContext().getResources();
int fourDp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, r.getDisplayMetrics());
final String toolbarColour = "#EE7C0E";
Toolbar mMasterToolbar = findViewById(R.id.my_toolbar);
setSupportActionBar(mMasterToolbar);
mMasterToolbar.setBackgroundColor(Color.parseColor(toolbarColour));
mMasterToolbar.setElevation(fourDp);
mMasterToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
final TextView mTitle = this.findViewById(R.id.toolbar_1line_title);
mTitle.setText(getString(R.string.london_overground));
FragmentMain newFragment = new FragmentMain();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.master_container, newFragment);
transaction.commit();
}
}
最佳答案
您的工具栏
中缺少android:background
。
示例:
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/my_toolbar"
android:elevation="4dp"
android:background="?attr/colorPrimary"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:minHeight="?android:attr/actionBarSize">
注意:为了将标高应用到任何 View ,它需要有背景。
<小时/>编辑:由于您的应用的最低 SDK 版本为 24,因此您可以使用 translationZ
属性。
关于java - 尽管设置了属性,但 AppCompat 工具栏标高缺失(使用 RecyclerView),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53156642/
升级/重构到 AndroidX 后我收到这个错误androidx.appcompat.appcompat.R 不存在在代码中显示 appcompat 符号无法解析 最佳答案 我遇到了和你一样的错误信息
我在使用 AppCompat 时突然想到,我一直在布局 XML 文件中使用 Button 而不是 android.support.v7.widget.AppCompatButton 之类的东西。我通过
我刚刚升级到 AppCompat v23,发现 setSupportProgressBarIndeterminateVisibility 已弃用。但是,我无法找到替代方案,文档对此似乎非常薄弱。 如果
可以像这样使用 CoordinatorLayout 和自定义 FloatingActionButton: Futuresimple - FloatingActionButton 或 Clans - F
我正忙着尝试实现支持库,以便我可以使用 AppCompatActivty 据我所知,我把所有东西都放在了正确的地方。但我仍然收到错误。 样式.xml
有以下 Theme.AppCompat 类: Theme.AppCompat Theme.AppCompat.Light Theme.AppCompat.Light.DarkActionBar The
我更新了compileSDkversion从 27 日到 28 日。 添加于 gradle.properties文件: android.useAndroidX=true android.enableJ
我正在尝试构建一个 react native 应用程序,但它返回此错误: > Could not resolve all task dependencies for configuration ':a
我正在迁移到 androidX,但我收到: Could not find androidx.appcompat:appcompat:1.0.2. Required by: project :a
我正在尝试升级我的 gradle。当我将 appcompat 从 1.0.2 更新到 1.1.0 时,我的 webview 在某些手机上不再工作。 (API 21 和 22)。 有没有一种聪明的方法可
我是 Android 开发的绝对初学者,并尝试构建测试自动化来测试移动应用程序。经过数周的 IntelliJ 设置后,我仍然面临问题,其中包括以下问题。 因为我使用的是 SDK ver 29,我被告知
我正在使用 v7 appcompat 支持库。操作项在 actionBar 中显示的工作在较新或较旧的设备上都很好。 但是,我没有在 API 7 上得到溢出。例如: appco
最新链接app-compat这是1.1.0 . 将我的应用程序升级到最新版本后 app-compat我的语言设置在 以下的手机上停止工作API 24 (粗略地说,肯定不适用于 API 21 及以下版本
这里的 iOS 开发人员被扔进了 Android 项目的狼群中。我收到一些错误代码,它们都表示类似于 ThemeUtils: View class androidx.appcompat.widget.
这里的 iOS 开发人员被扔进了 Android 项目的狼群中。我收到一些错误代码,它们都表示类似于 ThemeUtils: View class androidx.appcompat.widget.
我最近将我的应用程序升级为 Material 主题。但是,我在 4.2.2 三星平板电脑上遇到崩溃。堆栈跟踪(在下面发布)告诉我我没有使用 Theme.AppCompat 的后代,尽管我相信我是。该应
我正在使用 AppCompat 22.1.1 Base.Widget.AppCompat.Button 和 Widget.AppCompat.Button 有什么区别? 最佳答案 在 AppCompa
我已经在多个地方看到了这个问题。问题似乎与过去的gradle版本3和android studio版本3的更新有关。每当我将依赖项更改为较新的版本时,我都会不断收到错误消息: Could not fin
我已将此资源添加到我的项目中,它向我显示了一个警告。 我该如何解决? The problem still continues (I don't know, if I
我为建议行定义了一个布局,但在将 AppCompat 库更新到 22.1 后,忽略了 styles.xml 中定义的布局。 这是我的 styles.xml 文件(已简化): @style/S
我是一名优秀的程序员,十分优秀!