I'm making a custom ActionBar for the first time. I was using the Theme.AppCompat.Light, but noticed that there is still space to the left of my custom view.
I made a test app to analyze the effect of altering different ActionBar elements, here are the comparisons.
How can I remove that annoying space?
This is what I want!
theme: Theme.Holo.Light
This is what I'm getting with material theme, LOOK AT THAT ANNOYING SPACE!
theme: Theme.Material.Light
Here are with the other toggle buttons checked
This happens because you are selecting DeviceDefaultTheme. You could use android:style/Theme.Holo.Light.DarkActionBar for action bar.
You need to add:
app:contentInsetEnd="0dp"
app:contentInsetStart="0dp"
which app is
xmlns:app="http://schemas.android.com/apk/res-auto"
Related
I am using 'Theme.MaterialComponents.Light.DarkActionBar' as my AppTheme.I want to change the back ground to a custom state-list drawable. But the problem is that the back ground is not changing at all, it still shows the primary color as back ground.
All i want to achieve is a group of buttons having triangular shape like this.
if i use 'Base.Theme.AppCompat.Light.DarkActionBar' as my AppTheme, everything works fine. But just changing the AppTheme to Material, the button group change to normal material style button as shown.The material theme is not setting the back ground to my state-list drawable. I tried with android:backgroundTint but not able to set a state-list as background.
This is my xml for one button.
<Button
android:id="#+id/forwardbtn"
android:layout_width="#dimen/joystick_mov_btn_size"
android:layout_height="#dimen/joystick_mov_btn_size"
android:layout_marginBottom="#dimen/joystick_mov_btn_size"
android:background="#drawable/arrow_btn"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:rotation="270"/>
I don't want to change the AppTheme from material theme. I am using this approach is because i couldn't find any easy way to change the button shape other than this. I am spending too much time on this simple stuff please help..
How to remove the shadow in ActionBar ?
For Example :
When I touch my icon,the shadow appear,so how to remove it?
[ADD] It's different from ToolBar,when I use ToolBar Theme,I got a resource not found error.
[ADD] This app is running at Android 4.4
Maybe this is useful.I set
<item name="android:actionBarItemBackground">#color/actionbar_button_background</item>
Which the 'actionbar_button_background' is same of the ActionBar background Color.
I want my menu items on the BottomNavigationBar to have text-only labels with no icon. Unfortunately, it looks like design_bottom_navigation_item.xml always has a 24x24dp space reserved for the icon, with no publicly-exposed way to set it to gone. And even after getting past that, the label layout is set to a layout_gravity of bottom|center_horizontal, and it doesn't look like there's a way to programatically set layout_gravity to centered.
What is the fastest, easiest way to achieve the goal of a text-only menu item on the bottom nav bar? I'm thinking I can do this by creating a custom version of the item layout, then subclassing BottomNavigationItemView, BottomNavigationMenuView, and BottomNavigationView to specify that custom layout... but that seems like an awful lot of work for one little change. Am I missing something simpler?
dont put iandroid:icon property to your item
Just use the code below. I tried hard to do this easy way but failed.Then I made an alternative. Just use transparent color instead of icon drawble
<item
android:icon="#android:color/transparent"
android:id="#+id/navigation_id"
android:title="title" />
Add this in your dimens file. Then you can add padding according to your navigation view size.
<dimen name="design_bottom_navigation_height"tools:override="true">30dp</dimen>
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.
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"
>