views:

43

answers:

1

Hi,

I've created a custom titlebar for my Android application. All is well except I've placed a checkbox on the titlebar and I want my checkbox to be positioned farther left (so I can line it up with the checkboxes in each list item). I can not figure out how to move it farther left. It's almost like that's as far as it will let me put it. Here is a screenshot of what I mean as well as my titlebar XML:

http://i28.tinypic.com/2dpfn9.png

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    style="?android:attr/windowTitleBackgroundStyle"
    android:layout_height="?android:attr/windowTitleSize"
    >
    <CheckBox
  android:id="@+id/inbox_selectall"
  android:text=""
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:gravity="left|center_vertical"
  android:focusable="false"
  android:background="@drawable/checkbox_background"
  android:button="@drawable/checkbox"
 />
 <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_centerVertical="true">
  <TextView
   xmlns:android="http://schemas.android.com/apk/res/android"
   style="?android:attr/windowTitleStyle"
     android:id="@+id/inbox_title"
     android:text="@string/title_inbox"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:gravity="center_vertical|center_horizontal"
     android:background="@null"
         android:fadingEdge="horizontal"
         android:scrollHorizontally="true"
 />
 </LinearLayout>
</RelativeLayout>
A: 

One thing to note is that when you set android:background to a 9-patch, you assume its padding. For the title bar graphic, there are a few pixels of left-padding (see the bottom row of pixels). I don't remember off the top of my head, but you may be able to override it using android:padding.

Roman Nurik
Indeed, the issue is the 9-patch padding, the area where you can write does not go to the left, there are a few pixel.Well spotted.
Sephy