Actionabar issues coming from full screen - java

I got a full screen activity that leads to an activity with an action bar. When the scond activity loads, the actionbar is half hidden by the title menu.
Why is this happening and what can I do to prevent it?
EDIT: as seen below, the title bar hides some of the action bar.

1 ) You have to keep same theme for all activity ,put actionbar activity them in application tag in manifest file
2) If you want to use full screen activity then getSupportActionBar().hide(); If you have Simle activity and Actionbar activity then while launching simple Actionbar activity to Simple activity creates problem.

check your activity deceleration in the manifest file. Declarer your activity like this.
<activity
android:name="com.android.MainActivity"
android:theme="#android:style/Theme.Light.NoTitleBar">
</activity>

Related

How to back from the activity without button

When I was browsing the slack application I found new feature I liked, which is the return of activity by dragging without pressing the back button as usual.
So is there a specific code to do that? I did a research on how to do that but I couldn't find any explanation for it, so how can I do that.
Here is a short video about the new feature
click here
Thanks to Coding in flow for that. Watch this tutorial for more explanation.
Follow these steps to do the job.
1- We will use a library to do that called Slidr, use the last version.
// swipe the Activity to close
implementation 'com.r0adkll:slidableactivity:2.1.0'
2- Add a new style in your styles.xml called SliderActivityTheme.
This theme will make the background for the activity when swipe it as transparent to show the content of the fragment...etc, "default background white"
<!--Theme for Slider Activity-->
<style name="AppTheme.SliderActivityTheme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
</style>
3- A- Add slide method to your class and called in OnCreate
// Make slider on the Activity
public void Slider () {
Slidr.attach(this);
}
B- Called in OnCreate
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_activity_name_here);
// slider the activity
Slider();
}
or just simply add this in your OnCreate directly
// slider the activity
Slidr.attach(this);
4- In your AndroidManifest.xml add the theme that we had to create.
android:theme="#style/AppTheme.SliderActivityTheme"
Make it like that
<activity
android:name=".Activity.ActivityImages.ImagesMorningActivity"
android:launchMode="singleTop"
android:theme="#style/AppTheme.SliderActivityTheme"/>
<activity
That's all, and enjoy with your new feature ;)
Working with Fragment? No problem, check the library page to know how to do that

Can't find listener for bar icon

I'm working on an app that, thought the method setHomeAsUpIndicator, replaces the title of the activity. So far everything makes sense because it can be understood by reading the documentation, but I can't figure out why, when I press the icon, a certain Activity is launched.
This specific part of the code looks like this:
private void myMethod() {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(
ContextCompat.getDrawable(this, R.drawable.someIcon)
);
actionBar.setHomeActionContentDescription(
getResources().getString(R.string.correspondingDescription)
);
actionBar.setDisplayShowTitleEnabled(false);
}
When someIcon is pressed, another Activity is launched, but I don't know where is that indicated.
Thanks for the help!
It moves to previous activity because there is a parent activity set in a AndroidManifest.xml file, like this :
<activity
android:name=".ExampleActivity"
android:parentActivityName=".MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity"/>
</activity>

Move EditText (or a layout) above the keyboard when you click a fab

So, I saw that thing in the Todoist app. When you click the add fab, the keyboard pops up with some layout above it where you can enter text and set some things. How can I do it?
This is how the thing actually looks:
Is there some example on how this is done?
(please don't mind that this is the iOS version of the app, I don't own a android device)
Make bottom sheet with fragment and edit text in fragment,and set button fab to show bottom sheet when clicked,,you can set the bottomsheet visibility GONE if you want
Add this android:windowSoftInputMode="stateHidden"
line in your Activity block in manifist.xml file like this
<activity
android:name=".Activities.DashboardActivity"
android:label="#string/title_activity_dashboard"
android:windowSoftInputMode="stateHidden"
android:theme="#style/AppTheme.NoActionBar">
</activity>

Android: Swipe-able Fragment "onTabSelected"

I have a 2 fragments, fragment adapter, sliding tab layout, sliding tab strip and main activity.
How do i change the action bar text when i change tab like when user select tab1 the action bar text is home and tab 2 action bat text is profile.
also how do i change to tab text to icon.
for my final year project please help thanks :D
Guide for the sliding tab: http://www.android4devs.com/2015/01/how-to-make-material-design-sliding-tabs.html
it crashed when i add
getActivity().getActionBar().setTitile("required title as per
fragment");
in the fragment #Override onResume
LogCat error Attempt to invoke virtual method 'void
android.app.ActionBar.setTitle(java.lang.CharSequence)' on a null
object reference
In onResume() of each fragment you can get actionbar like getActivity().getActionBar().setTitile("required title as per fragment");
i hope this will solve you problem

why does my android keyboard opens automatically?

I have this Layout.
every time it's opened, the android keyboard appears
why is that?
how can I avoid this?
Add this to your manifest file, You can avoid that.
<activity
android:name="Your_Activity"
android:windowSoftInputMode="stateAlwaysHidden" >
</activity>
If the EditText has requestFocus,then keyboard might display automatically. It has nothing to do with your xml code.
Add the following line to your Manifest File inside each Activity tab
android:windowSoftInputMode="stateAlwaysHidden"
or add the following to your parent layout in that activity
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
Strange ! I thought Screen which has editText only get focus.
Try this => Stop EditText from gaining focus at Activity startup
Android opens the OnScreenKeyboard automatically if you have an EditText focussed .
You can prevent that by adding following into your Activity's onCreate method.
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

Categories

Resources