App Bar does not appear

0

In fact it even appears in the program, but not in the simulator

Following the Java code

    public class Perguntar extends AppCompatActivity{

    @Override
    protected void onCreate (Bundle savedInstance) {
        super.onCreate(savedInstance);
        setContentView(R.layout.activity_perguntar);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
    }
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.feed, menu);
            return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Faz com que items da action Bar se tornem clicáveis
        // como vc sepecificar no AndroidManifest.xml.
        int id = item.getItemId();

        return super.onOptionsItemSelected(item);
    }

    public void voltar (View view) {
        Intent back = new Intent(getApplicationContext(), Feed.class);
        startActivity(back);
    }

    public void perguntado (View v) {
        Toast.makeText(Perguntar.this,
                "Pergunta enviada com sucesso, aguarde respostas",
                Toast.LENGTH_LONG).show();
    }
}

Now the manifest file:

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme.Limpar">
    <activity
        android:name=".SplashScreen"
        android:theme="@style/AppTheme.TelaCheia"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".TelaDeLogin"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="stateHidden"/>

    <!--o orientation portrait define que a tela ficara apenas em modo portrait (vertical)-->
    <!-- o inputmode "statehidden" faz com que o teclado não seja aberto automaticamente -->

    <activity
        android:name=".TelaDeCadastro"
        android:label="@string/cadastrar"
        android:theme="@style/AppTheme"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="stateHidden"/>
    <activity
        android:name=".Feed"
        android:label="@string/T_Feed"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="stateHidden"/>
    <activity
        android:name=".Perfil"
        android:label="@string/T_Perfil"
        android:screenOrientation="portrait"/>
    <activity
        android:name=".Editar_Perfil"
        android:label="@string/T_Edicao"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.Limpar"/>
    <activity
        android:name=".Escolha"
        android:label="@string/T_Escolha"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme" />
    <activity android:name=".Anuncios"
        android:screenOrientation="portrait"/>

    <activity
        android:name=".Estagio"
        android:theme="@style/AppTheme"
        android:label="@string/T_Estagio"
        android:screenOrientation="portrait"/>

   <activity  
        android:name=".Perguntar"
        android:label="@string/T_Perguntar"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="stateHidden"/> 

    <activity
        android:name=".Respostas"
        android:theme="@style/AppTheme.Limpar"
        android:label="@string/T_Respostas"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="stateHidden"/>

</application>

the appbar code:

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="end"
        android:background="#2138e1"
        android:theme="@style/AppTheme.AppBarOverlay"
        android:visibility="visible"
        app:layout_anchorGravity="top"
        app:layout_scrollFlags="scroll"
        app:popupTheme="@style/AppTheme.PopupOverlay"
        app:title="@string/T_Perguntar"
        app:titleMarginStart="100dp" />



</android.support.design.widget.AppBarLayout>

<include
    android:id="@+id/app_bar_perguntar"
    layout="@layout/activity_perguntar"
    app:layout_anchor="@+id/include"
    app:layout_anchorGravity="center"/>

<ImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    tools:src="?attr/homeAsUpIndicator"
    android:layout_gravity="top"
    android:layout_marginTop="@dimen/espacamento_Medio"
    android:background="@color/transparente"
    app:layout_anchorGravity="start"
    android:onClick="voltar"
    />

The activity code:

<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".Perguntar"
    android:background="@color/preto"
    tools:showIn="@layout/app_bar_perguntar"
    android:theme="@style/AppTheme.Limpar">

    <include layout="@layout/criar_pergunta"></include>

</android.support.constraint.ConstraintLayout>

And finally, the layout:

<ImageView
    android:id="@+id/fotoPublicante"
    android:layout_width="@dimen/foto_Perfil"
    android:layout_height="@dimen/foto_Perfil"
    android:layout_marginStart="@dimen/espacamento_Medio"
    android:layout_marginTop="@dimen/espacamento_Medio"
    android:background="@color/preto"
    android:contentDescription="@string/todo"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.0" />

<TextView
    android:id="@+id/nomePublicante"
    style="@style/TituloPublicacao"
    android:layout_margin="@dimen/espacamento_Medio"
    android:text="@string/maycon_santos"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toEndOf="@id/fotoPublicante"
    app:layout_constraintBottom_toTopOf="@id/suapergunta"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.5" />

<EditText
    android:id="@+id/suapergunta"
    style="@style/FontePublicacao"
    android:layout_width="match_parent"
    android:layout_height="@dimen/altura_sua_pergunta"
    android:layout_margin="@dimen/espacamento_Medio"
    android:text="@string/pergunta"
    android:textColor="@color/blue"
    android:gravity="start"
    app:layout_constraintBottom_toTopOf="@id/anexar"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@id/fotoPublicante"
    app:layout_constraintVertical_bias="0.1" />

<ImageButton
    android:id="@+id/anexar"
    android:layout_width="wrap_content"
    android:layout_height="@dimen/altura_Caixa_De_Testo"
    android:layout_margin="@dimen/espacamento_Medio"
    android:background="@color/transparente"
    android:src="@android:drawable/ic_menu_camera"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintBottom_toTopOf="@id/buttonSend"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@id/suapergunta"
    app:layout_constraintVertical_bias="0.0" />

<Button
    android:id="@+id/buttonSend"
    style="@style/BotaoComFundo"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="@dimen/espacamento_Medio"
    android:onClick="perguntado"
    android:text="@string/enigma"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintBottom_toTopOf="@id/anexar"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@id/anexar"
    app:layout_constraintVertical_bias="0.5" />

</android.support.constraint.ConstraintLayout>

Could anyone help me?

    
asked by anonymous 03.08.2018 / 18:51

1 answer

0

I already found the error, was duplicating the app_bar, once settling in java and calling somehow twice in xml, sorry for my mistake.

    
26.11.2018 / 02:11