JakeWharton / ActionBarSherlock

[DEPRECATED] Action bar implementation which uses the native action bar on Android 4.0+ and a custom implementation on pre-4.0 through a single API and theme.
http://actionbarsherlock.com
Apache License 2.0
7.1k stars 3.53k forks source link

Black area is showing at left side in Action Bar Sherlock #1103

Open williams-sgvu opened 10 years ago

williams-sgvu commented 10 years ago

Hello I am using Sherlock library to achieve the ActionBar Tabs. Here I am setting custom title and want to hide the icon at the title bar but some issue that ActionBar tabs now appearing at above of ActionBar.

I see this issue here https://github.com/JakeWharton/ActionBarSherlock/issues/327#ref-issue-7764467

so I am trying to solve this issue using that working but that is creating other issue.

@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tariff_plans_layout);

ActionBar actionBar = getSupportActionBar();

if(Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
    actionBar.setLogo(new ColorDrawable(Color.TRANSPARENT)); 

    View homeIcon = findViewById(
            Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ? 
            android.R.id.home : R.id.abs__home);
    ((View) homeIcon.getParent()).setVisibility(View.GONE);
    ((View) homeIcon).setVisibility(View.GONE);
}

actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);

View actionbar = LayoutInflater.from(this).inflate(R.layout.custom_title_bar, null);
getSupportActionBar().setCustomView(actionbar);
actionBar.setDisplayShowCustomEnabled(true);

} but here now ActionBar title is looking like below, see there is left black area so I am looking to remove this with my color so my question Is there any way to remove that black area ?

custom_title_bar.xml

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/relativeLayout1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/header_smartpay" android:orientation="horizontal" >

Below Android 3.0, I am having that issue but that is working perfectly above Android OS 3.0.

sn3pz

arunantoney commented 9 years ago

All workaround that post above collapsing the home icon but leaving a blank space. For avoiding that you need to set the logo size to zero . Below added my code snippet

actionBar.setLogo(new ColorDrawable(Color.TRANSPARENT));

      View homeIcon = findViewById(
                Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ? 
                android.R.id.home : R.id.abs__home);
        ((View) homeIcon.getParent()).setLayoutParams(new  LinearLayout.LayoutParams(0, 0));
        ((View) homeIcon).setVisibility(View.GONE);