Question

I have customised my title bar. The problem is though i have mentioned the width as fill_parent its not filling parent with some blank space on either sides

the code is below

<resources>
    <style name="LargeTitleTheme">
        <item name="android:windowTitleSize">40dip</item>
    </style>
</resources>

xml2:

<RelativeLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        <TextView android:id="@+id/textview" android:textStyle="bold"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:gravity="center" android:text="fggffgjjkki"
            android:textSize="30sp"
                        android:textColor="#FFFFFF" android:background="@drawable/top_bar" />
</RelativeLayout>

code:

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        setContentView(R.layout.homegrid);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.customtitle);
Was it helpful?

Solution

I had faced the same problem, to the left and right of the title, there were some gray color padding.

Then I followed the steps discussed here, Android: Custom Title Bar, and specify the background color in the custom style same as the custom title background color. Then it works!

  • Herojit

OTHER TIPS

Try adding android:layout_marginLeft="0dp" android:layout_marginRight="0dp" to the RelativeLayout.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top