I want to customize ActionBarSherlock tabs and tab bar.It is like this.
I want make it like this
You could use a custom view to display the tabs. You could try a 3-arg LinearLayout constructor (added in API 11). By specifying a default style in an XML file, the library tends to leverage the system layout inflator. So, you can also do a similar work around
<LinearLayout style="?attr/actionBarTabStyle" />
And then add the below code
LineraLayout tabView = LayoutInflater.from(context).inflate(R.layout.my_tab, null);
//set your layout params and setCustomView
Here is two links which will help you to customize ABS.
Customize ActionBar TabBar (ActionBarSherlock)
And
How to customize ActionBar in Android (ActionbarSherlock)?
basically you need to make changes in ABS themes and have to play with its drawable.
Related
I read about Android styles and themes today and tried to apply it to a list in my app as a test. The app has a list element which have TextViews added to it programmatically.
According to the docs applying a style as a theme affects child views too.
So I tried this:
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/TextAppearance.AppCompat.Small"/>
I expected that the TextView texts in the list became small, but nothing happened.
I also tried #style/TextAppearance.MaterialComponents.Headline1, but it had no effect either.
Why is that?
I didn't change any of the style or theme settings myself. I use the default settings which Android Studio generated for the project.
Shouldn't applying a style as a theme to a view like above change something?
You are using the style "TextAppearance.AppCompat.Small" which is applicable to a TextView and not a generic one like ListView.
You need to apply the style to the list item which is the TextView. You can create a custom style for text appearance, font, sizing, etc and reuse it in your entire app.
If you are creating your views programmatically, you can use a custom adapter (which extends your default adapter), override getView method to apply your style. Refer this
Refer to this awesome article by #Nick Butcher
I have a hard time finding on how to change the Toolbar title and it's drawable in every and each Activity.
There is something on Android Documentation that states that to minimize APK size. It is recommended to re-used components.
I create a separate layout, and <include layout=""/> to each of my Activities like Help, About , and etc. I also put android:label="Title" on Manifest File.
Toolbar.xml
My Main:
How do I access this included Toolbar DRAWABLE and TITLE in my Activities ?
Update: I removed ActionBar .
You are using Toolbar. So no need to do anything with ActionBar. Just set your Toolbar as supportActionBar. Then set title and icon to your Toolbar.
Use the below code:
mToolbar = (Toolbar)findViewById(R.id.Toolbar);
setSupportActionBar(mToolbar);
setTitle("About");
getSupportActionBar.setIcon(R.id.ic_arrow_back_black_24dp);
And, Remove all your mActionBar codes. Hope this helps.
well you set the support action to your custom toolbar,yet you ignore it and use mActionBar, see where i am going with this? setIcon , and setTitle should all be called relative to your custom toolbar.
I would like to create swipeable tabs without action bar at its top as shown as in the link. I've used the following lines : setDisplayShowHomeEnabled(false);
setDisplayShowTitleEnabled(false);
Also here is my Layout xml.
Can anyone please help me how I can achieve this.
Your layout should be set up similar to this:
<LinearLayout>
<ToolBar/>
<TabBar/>
<ViewPager/>
</LinearLayout>
Also you should choose a theme without ActionBar (i.E. Theme.AppCompat.Light.NoActionBar) for your application, and not call setSupportActionbar()
Can I design my Android ActionBar like this?
If yes, give me a starter. I am not new to android design.
Application name with logo is already centered but the little red strip on bottom is difficult as fas as I can understand. If somebody can help.
create custom layout and design whatever you want then add that layout into the actionbar object.
ActionBar actionBar = getSupportActionBar(); //to support lower version too
actionBar.setDisplayShowCustomEnabled(true);
View customView=getLayoutInflater().inflate(R.layout.yourlayout, null);
actionBar.setCustomView(customView);
Create a custom layout according to your requirement in an xml file say,
activity_custom_actionbar.xml
Then include this in your java file using,
ActionBar actionBar = getActionBar();
actionBar.setCustomView(R.layout.activity_custom_actionbar);
getActionBar().setDisplayShowCustomEnabled(true);
The problem is the following one : on one of my activities, I needed a custom layout for my action bar, and the only way to do it like needed was to have a transparent ActionBar over my screen. In order to do that, I marked the ActionBar as overlay, and specified the action bar background as transparent. This works when using Android >= 15, but in 14 and below, the ActionBar keeps its bottom border. I tried anything to remove it, with no avail.
Here is a picture to see it more clearly :
On API 14 :
On API 16:
The design is the following : the Action Bar is supposed to be transparent and in overlay mode, and behind it there is a background + the logo
<ImageView
android:id="#+id/action_bar_background"
android:layout_width="match_parent"
android:layout_height="#dimen/action_bar_accueil_total_height"
android:layout_alignParentTop="true"
android:contentDescription="#string/action_bar"
android:scaleType="fitXY"
android:src="#drawable/actionbar_logo_extended" />
<ImageView
android:id="#+id/home_gallica_logo"
android:layout_width="#dimen/largeur_logo_carrousel"
android:layout_height="#dimen/action_bar_accueil_total_height"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:contentDescription="#string/action_bar"
android:src="#drawable/logo_fullcolor" />
Some precisions : I use ABS, but this does not seem to be the source of the problem, as switching to the v7 support library did exactly the same thing.
Do anyone has an idea how to remove this bottom border ?
Following the advice and the test by Luksprog in the comment, I used Theme.Sherlock (instead of Theme.Sherlock.Light) in my action bar for this page, and copied from my old theme the settings I needed. This seems to have resolved the problem, but I'm not completely sure of the source. The only advice I can give to people who are going to see this will be to use Theme.Sherlock.
I've tried to make a simple activity to showcase the behavior but I didn't manage to do it. I used an Activity with the theme Theme.Sherlock:
android:theme="#style/Theme.Sherlock
and to make the overlay(in the onCreate() method):
requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); // Window from com.actionbarsherlock.view
//...
setContentView(content);
ActionBar ab = getSupportActionBar();
ab.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
You can hide the action bar at by calling hide() method:
ActionBar actionBar = getSupportActionBar();
actionBar.hide();
Or you can set this in your manifest if you want to hide it permanently:
<activity
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
>