Почему в макете не отображается ImageView

Почему у меня в макете не отобраается ImageView ? Это как должно быть Это как должно быть

И как отображается И как отображается

activity_main_menu.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background"
tools:context=".Main_menu">

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="#3354B5"
        android:layout_alignParentBottom="true"
        android:orientation="horizontal">


        <ImageView
            android:id="@+id/user4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_weight="1"
            tools:src="@drawable/ic_user" />

        <ImageView
            android:id="@+id/user2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_gravity="center"
            tools:src="@drawable/ic_user" />

        <ImageView
            android:id="@+id/user3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_gravity="center"
            tools:src="@drawable/ic_user" />
    </LinearLayout>

Main_menu.java

package com.example.centus;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
public class Main_menu extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_menu);

        androidx.appcompat.widget.Toolbar toolbar = findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayShowTitleEnabled(false);
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.toolbar_menu, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        switch (item.getItemId()){
            case R.id.exit:
                onExit();
                return true;
        }
        return true;
    }
    public void onExit(){
        Intent intent = new Intent(this,MainActivity.class);
        startActivity(intent);
    }
}

Ответы (2 шт):

Автор решения: Yauheni Bartoshyk

Может кому-нибудь пригодится

Мне помогло решить эту задачу добавив этот фрагмент кода в Main_menu.java

ImageView photo = (ImageView) findViewById(R.id.user4);
int image = R.drawable.ic_user;
photo.setImageResource(image);
→ Ссылка
Автор решения: Никита Жуков

Надо добавить в

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background"
tools:context=".Main_menu">

это:

android:orientation="vertical"

У меня была такая же проблема, и я её исправил этой строчкой.

→ Ссылка