操作栏图标,使能不称号 [英] Action Bar icon as up enabled not the title
本文介绍了操作栏图标,使能不称号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使在actionbarsherlock使能(并非仅标题图标)的应用程序图标,像什么应用程序。
How to make app icon as up enabled in actionbarsherlock (not the title only icon) like in whats app.
推荐答案
该题联是可以点击与由于Android 4.2.2的图标。 WhatsApp的使用自定义视图来显示两行标题。这将禁用标题点击前进的道路上。你可以用同样的方式:
The title is clickable together with the icon since Android 4.2.2. WhatsApp uses a custom view to display a two line title. This disables the title click along the way. You can do it the same way:
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(R.layout.ab_title);
TextView title = (TextView) findViewById(android.R.id.text1);
title.setText("Title");
/res/layout/ab_title.xml:
/res/layout/ab_title.xml:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="@style/TextAppearance.Sherlock.Widget.ActionBar.Title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="end"
android:gravity="center_vertical" />
这篇关于操作栏图标,使能不称号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文