【发布时间】:2016-07-14 05:10:43
【问题描述】:
我没有使用 Toolbar 或 ActionbarActivity 。我正在使用普通活动。我的活动是有一个 actionbar 。我想以这样的方式自定义它,使活动的标题在中间对齐,并且有一个带有一些文本的后退按钮。喜欢这张图片
。我正在为我的操作栏使用自定义布局,设计还可以,后退按钮也可以使用。但问题是带有后退按钮的文本是可点击的。
这是我尝试过的
getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getActionBar().setCustomView(R.layout.custom_actionbar_title);
getActionBar().setDisplayHomeAsUpEnabled(true);
custom_actionbar_title 的布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="16.0"
android:weightSum="16.0">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:text="Incidents"
android:gravity="left"
android:layout_weight="5"
android:textColor="#ffffff"
android:id="@+id/backButtonText"
android:textSize="18sp" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAlignment="center"
android:layout_weight="6"
android:text="Detail"
android:gravity="center"
android:textColor="#ffffff"
android:id="@+id/title"
android:textSize="18sp" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text=""
android:layout_weight="5"
android:layout_gravity="end"/>
</LinearLayout>
【问题讨论】:
标签: android android-actionbar back-button