Buttons Not Visible on the Application. What's Wrong

Buttons not visible on the application. What's wrong?

To quickly add constraints to your layout just click on the Infer Constraints Sample Image button in the Layout Editor toolbar. Learn more about the feature here: https://developer.android.com/training/constraint-layout/index.html#use-autoconnect-and-infer-constraints

Buttons not showing up in Android Studio

I just pasted your code directly into a new project and it works fine. Make sure that you're wrapping your components in another layout. Here is what I wrapped your XML with:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.test.MainActivity">
<!-- The rest of your code goes here -->
</android.support.constraint.ConstraintLayout>

Here is what it looks like on my tablet:
Sample Image

Android Button shows in graphical layout but not on device

Your xml file is never being used.

The setContentView() for your activity contains activity_main.

Check your layout activity_main - set a button inside and run the code as it is, you will see that button.

What you want is to set fragment_main.

One way to do it is:

public class MainActivity extends Activity //or ActionBarActivity--considering it extends activity
{
        @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        if (savedInstanceState == null)
        {
            getFragmentManager().beginTransaction()
                    .add(R.id.container, new PlaceholderFragment()).commit();
        }
    }
 
        public static class PlaceholderFragment extends Fragment
    {
 
        public PlaceholderFragment()
        {
        }
 
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState)
        {
            View rootView = inflater.inflate(R.layout.fragment_main, container,
                    false);//here is your fragment layout
            return rootView;
        }
    }
}

Further ref:

1. Example: sample default

2. Multi pane development: fragments

3. How to work with fragments - android

Action button is not showing in the notification when the application is in background

As there's no any code provided I can't say what's the specific issue here, butt keep in mind. In FCM there are 2 types of notifications:

  • Notification payload
  • Data payload

When you send a notification from FCM, it is a notification payload. In this case if your app is killed, the notification will go directly to the system tray and will be handled by the OS. The onMessageReceived() won't execute.

If you send the notification from the backend side, it's a data payload. In that case the onMessageReceived() will be executed.

Check more here FCM Message Types

Menu buttons not showing up on toolbar in Android app creating through androidstudio

Very basic errors..
A-> In ActivityMain.java

  1. import androidx.appcompat.widget.Toolbar
    instead of import android.widget.Toolbar; as rightly said by @Mayur Gajra
  2. Initialize androidx.appcompat.widget.Toolbar mToolbar instead of android.widget.Toolbar mToolbar
  3. Set mToolbar = (androidx.appcompat.widget.Toolbar) findViewById(R.id.toolbar);
    and not as mToolbar = findViewById(R.id.toolbar);
  4. Use setSupportActionBar(mToolbar); instead of setActionBar(mToolbar);

B-> In v21\toolbar.xml

  1. Replace <Toolbar xmlns:android="http://schemas.android.com/apk/res/android" with <androidx.appcompat.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"

C-> Change Theme.AppCompat.Light.DarkActionBar to Theme.MaterialComponents.DayNight.NoActionBar.Bridge as accurately pointed out by @Mayur Gajra



Related Topics



Leave a reply



Submit