gpt4 book ai didi

android - setDisplayHomeAsUpEnabled 显示箭头而不是左插入符

转载 作者:太空宇宙 更新时间:2023-11-03 11:48:52 27 4
gpt4 key购买 nike

我想在我的 Activity 中显示向上按钮,该功能运行良好,但无法显示左插入符号。相反,它显示了一个丑陋的后退箭头。我在我的 Activity 中这样做 -

public class SecondActivity extends ActionBarActivity{

@Override
protected void onCreate(Bundle savedInstanceState) {

mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
setTitle(getString(R.string.second));
mToolbar.setTitleTextColor(getResources().getColor(android.R.color.white));

....
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
....

}
}

但我只看到了这个 -

Back Arrow

这是布局 xml -

<FrameLayout 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="org.step.main.SecondActivity">

<android.support.v7.widget.RecyclerView
android:id="@+id/listsecond"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="?attr/actionBarSize"
android:clipToPadding="false"
tools:context=".SecondActivity"
/>

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"/>

</FrameLayout>

有什么建议吗?另外,有没有办法将后退按钮的颜色更改为白色?

注意:我正在使用主题 - Theme.AppCompat.Light.NoActionBar

最佳答案

正在关注 this answer ,您可以使任何图标显示为白色。

至于左边的克拉图标,看看this answer ,它描述了在 Action Bar Icon Pack 中找到它的位置您需要下载。

编辑:你想要的图标位于 Action Bar Icons/holo_dark/02_navigation_previous_item/

要将左箭头显示为白色,您可以这样做:

    mToolbar.setTitleTextColor(getResources().getColor(android.R.color.white));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

//Add the following code to make the up arrow white:
final Drawable upArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
upArrow.setColorFilter(getResources().getColor(android.R.color.white), PorterDuff.Mode.SRC_ATOP);
getSupportActionBar().setHomeAsUpIndicator(upArrow);

请注意,您需要添加这些导入:

import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;

关于android - setDisplayHomeAsUpEnabled 显示箭头而不是左插入符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30379832/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com