我創建了一個自定義操作欄對齊自定義操作欄
ActionBar actionBar = getActivity().getActionBar();
actionBar.setCustomView(R.layout.action_bar_draft);
actionBar.setDisplayShowCustomEnabled(true);
actionbarFeed = (TextView) actionBar.getCustomView().findViewById(R.id.textView_blogtest);
actionbarFeed.setText("My Photos and videos");
問題是文本視圖不對齊中心
在我的佈局文本視圖爲中心。當它來到行動吧時,它被轉移到右側。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true" >
<TextView
android:id="@+id/textView_blogtest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000" />
</RelativeLayout>
<style name="AppTheme.ActionBarStyle" parent="@style/Widget.Sherlock.ActionBar.Solid">
<item name="android:icon">@drawable/menu</item>
<item name="android:background">#ffca36</item>
<item name="background">#f66605</item>
<item name="android:customNavigationLayout">@layout/action_bar</item>
</style>
您可以發佈您的自定義XML佈局嗎? –
是的。它解決了 – DKV