我希望在我的活动中显示一个“向上”按钮,这个功能已经正常工作了,但是我无法让左侧的尖号箭头显示出来。它只会显示一个丑陋的返回箭头。我正在我的活动中进行以下操作:
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);
....
}
}
但是我只看到这个 -
这是布局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
toolbar
的 XML 吗? - Daniel NugentgetSupportActionBar().setHomeAsUpIndicator ( R.drawable.your_custom_image);
就可以了。当我测试时,我成功地显示了ic_launcher
。看看这个:https://dev59.com/Q18d5IYBdhLWcg3weyI0 - Daniel Nugent