SlideMenu with Transparent Actionbar - android

with below code , i make a Transparent Actionbar for my FragmentActivity & all fragments:
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
ActionBar actionBar = getActionBar();
actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#64000000")));
setContentView(R.layout.main_slidemenu);
.
.
.
}
But i have a problem with this , i need to SlideMenu just open under actionbar , but it open i all of layout.

You are probably looking for the ActionBar overlay mode.
Enable it for a single Activity by calling requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); before setContentView(). Or in a theme by setting android:windowActionBarOverlay to true.

if you've used SlidingMenu library you could use :
setSlidingActionBarEnabled(false);
but according to the link you've provided you have used NavigationDrawer , with NavigationDrawer i think you could use layout_marginTop for your NavigationDrawer in it's layout xml and for better achievement , get your ActionBar height dynamically then set margin to that.
and also try removing line below:
getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
i've used NavigationDrawer before without setting Layout_marginTop and Window.FEATURE_ACTION_BAR_OVERLAY and its below my ActionBar.

Related

How To Change Included Toolbar Title And Drawable?

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.

Action Bar Title Text Color

I am having an Activity that extends the AppCompatActivity. I am using the theme Theme.AppCompat.Light.DarkActionBar. Now, the text color of the TitleText in the ActionBar shows up black. I want to set this color to white.
How can this be possibly achieved ?
Do I change the theme to something else (if yes then what) or can I change the color by making changes through the ThemeEditor available in the latest version of the Android Studio or can something be done with the getSupportActionBar() programmatically ?
I personally chose the programmatical way.
In your code, you can assign a custom layout to your ActionBar.
Like this:
android.support.v7.app.ActionBar mActionBar = getSupportActionBar();
mActionBar.setDisplayShowTitleEnabled(false);
mActionBar.setDisplayUseLogoEnabled(false);
mActionBar.setDisplayHomeAsUpEnabled(false);
mActionBar.setDisplayShowCustomEnabled(true);
mActionBar.setDisplayShowHomeEnabled(false);
ViewGroup actionBarLayout = (ViewGroup) getLayoutInflater().inflate(R.layout.topbarclassic,null);
mActionBar.setCustomView(actionBarLayout);
Then just change the text color of your textview containing the text inside the ActionBar as following:
android:textColor="#FFFFFF"
Try to do this way in your Activity
getActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#DCDCDC")));
You can simply change the action bar tittle color using this code
You add below code to your Oncreate method
setTitleColor(YOUR COLOR);
Hope this helps.

DialogWhenLarge adjustResize not working

The activity theme is Theme.AppCompat.Light.DialogWhenLarge. I can not get the activity to resize when keyboard is up. Configuring android:windowSoftInputMode="adjustResize" or getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
has no effect, all I'm getting is adjustPan behaviour. However, I can confirm that adjustNothing works. Any ideas how to make an activity with DialogWhenLarge theme to resize with keyboard?
Result with adjustResize:
Result with adjustNothing:
I've found a workaround, but would still like to hear if anyone had a similar problem.
Workaround:
Replaced Activity's theme DialogWhenLarge with Theme.AppCompat.Light.Dialog. This allows the adjustResize to behave as expected with ActionBarActivity
Added toolbar.xml layout as android.support.v7.widget.Toolbar
Assigned the toolbar as action bar in my Activity
Set activity's height for 10' tablets layout-sw720dp to 500dp for better presentation
Configure toolbar as action bar:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout...);
Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar);
setSupportActionBar(toolbar);
}
More on toolbar at android developer blog and stackoverflow

Android ActionBar design in API greater than 14

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);

Removing left arrow from the actionbar in android?

I want to remove the left arrow from the action bar and only icon and title needed.
My code:
getSupportActionBar().setIcon(R.drawable.logo);
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setTitle(R.string.dashboardtitle);
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
But this doesn't remove the left arrow . Any help!!
According to specification android specification:
To enable the icon for up navigation (which displays the "up" indicator next to the icon), call setDisplayHomeAsUpEnabled(true) on your ActionBar:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
...
}
So you should set actionBar.setDisplayHomeAsUpEnabled(false);
UPDATE:
I test next code with ActionBar sherlock and it's work. There is no back arrow:
getSupportActionBar().setIcon(R.drawable.ic_launcher);
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setTitle(R.string.about_event_location);
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
You need to add this to your actionBar theme. You can replace arrow image with your own image which can be transparent
<item name="android:homeAsUpIndicator">#drawable/action_arrow</item>
getActionBar().setHomeAsUpIndicator(R.drawable.action_arrow);
Where action_arrow is a 25x10px transparent png.
Same code for sherlock would be:
getSupportActionBar().setHomeAsUpIndicator(R.drawable.action_arrow);
#vivek: works great. I do not recommend to use #android:color/transparent as Tim Cooper said, because the Title is aligned to the left. So a empty image is better
In AndroidManifest.xml
remove the below code, which will remove back button from your ActionBar
android:parentActivityName=".Main.MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".Main.MainActivity" />
Just keep it like below:
<activity
android:name=".YourActivity"
android:label="#string/your_activity_label">
</activity>

Categories

Resources