Skip to content Skip to sidebar Skip to footer

Actionbarsherlock With Custom Relativelayout Does Not Show Title Text

The ActionBar does not show title when using relative layout. And when I not use the RelativeLayout, the items are not aligned to right. Please don't tell me to use menu items as t

Solution 1:

I had the same problem and found this link: https://groups.google.com/forum/?fromgroups=#!topic/actionbarsherlock/He6gst4nvR0

This worked for me:

layout:

<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="wrap_content"android:layout_height="wrap_content" >

    ...

</LinearLayout>

code:

import com.actionbarsherlock.app.ActionBar.LayoutParams;
...
LayoutParamslp=newLayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.RIGHT | Gravity.CENTER_VERTICAL);
getSupportActionBar().setCustomView(segmentView, lp);

Solution 2:

There is a workaround by adding TextView with titleTextStyle to the layout. If any of you have a better answer i'm looking forward to see it.

My workaround:

<?xml version="1.0" encoding="utf-8"?><RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="wrap_content"android:layout_height="wrap_content"><TextViewandroid:id="@+id/player_title"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_centerVertical="true"android:layout_toLeftOf="@+id/buttons_holder"android:ellipsize="end"style="@style/TextAppearance.Sherlock.Widget.ActionBar.Title"/><LinearLayoutandroid:id="@+id/buttons_holder"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_alignParentRight="true" ><ImageButtonandroid:id="@+id/acion_add"android:layout_width="wrap_content"android:layout_height="wrap_content"android:src="@drawable/menu_label_add"style="?attr/actionButtonStyle" /><ImageButtonandroid:id="@+id/action_prev"android:layout_width="wrap_content"android:layout_height="wrap_content"android:src="@drawable/menu_label_prev"style="?attr/actionButtonStyle" /><ImageButtonandroid:id="@+id/action_next"android:layout_width="wrap_content"android:layout_height="wrap_content"android:src="@drawable/menu_label_next"style="?attr/actionButtonStyle" /></LinearLayout></RelativeLayout>

Post a Comment for "Actionbarsherlock With Custom Relativelayout Does Not Show Title Text"